{ } $tests = ['Installation SIG Process' => function ($processor, $i) { $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] = [];
<?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');
* that can be found in the LICENSE file. */ require_once '__init__.php'; xp_import('unittest'); unittest\suite(function ($suite) { $suite->setup(function ($test) { $test->processor = new XPSPL\Processor(); }); $suite->teardown(function ($test) { unset($test->processor); }); $suite->test(function ($test) { $test->equal($test->processor->get_state(), STATE_DECLARED); }, 'Processor Construction'); $suite->test(function ($test) { $processor = new \XPSPL\Processor(false); $test->false($processor->signal_history()); $processor->emit(new \XPSPL\SIG('test')); $test->false($processor->signal_history()); }, 'construct_no_history'); $suite->test(function ($test) { $test->processor->signal(new \XPSPL\SIG('test'), new \XPSPL\Process(function () { })); $test->false($test->processor->has_signal_exhausted(new \XPSPL\SIG('test'))); $test->processor->emit(new \XPSPL\SIG('test')); $queue = $test->processor->find_signal_database(new \XPSPL\SIG('test')); $test->instanceof($queue, new \XPSPL\database\Processes()); // $test->count($queue->get_storage(), 0); }, 'auto_remove_exhausted'); $suite->test(function ($test) { // String based