<?php /** * Copyright 2010-12 Nickolas Whiting. All rights reserved. * Use of this source code is governed by the Apache 2 license * that can be found in the LICENSE file. */ require_once dirname(realpath(__FILE__)) . '/../__init__.php'; xp_import('unittest'); xp_import('time'); unittest\test(function ($test) { $processor = new \XPSPL\Processor(); $start = time(); $processor->signal(new \time\SIG_Awake(1, TIME_SECONDS), new \XPSPL\Process(function () use($start, $test) { $test->equal(1, time() - $start); }, 1)); $processor->wait_loop(); }, 'Time Module');
$processor->signal($i, xp_null_exhaust(null)); }, 'Emitting a signal' => function ($processor, $i) { $processor->emit($i); }, 'Registering a signal' => function ($processor, $i) { $processor->register_signal($i); }]; $output::send('Beginning performance tests ... please be patient.'); $results = []; $average_perform = 10; $total_tests = 0; foreach ($tests as $_test => $_func) { $results[$_test] = []; $processor = new \XPSPL\Processor(); $processor->signal_history(false); $sig = XP_SIG('a'); $processor->signal($sig, xp_null_exhaust(null)); for ($i = 1; $i < $average_perform + 1; $i++) { $output::send(sprintf('Running %s test %s of %s', $_test, $i, $average_perform)); for ($a = 1; $a < 1 << 10;) { $a = $a << 1; $tc = $a; if ($a === 1) { $setup = true; } else { $setup = false; } if (!isset($results[$_test][$tc])) { $results[$_test][$tc] = []; } for ($c = 0; $c < $tc; $c++) { // do the test