<?php use Zend\Loader\StandardAutoloader; use Zend\Feed\Reader\Reader; use Zend\Debug\Debug; //var_dump(dirname(__DIR__)); require_once dirname(dirname(__DIR__)) . '/vendor/ZF2/library/Zend/Loader/StandardAutoloader.php'; $loader = new StandardAutoloader(array('autoregister_zf' => true)); $loader->register(); class T extends Thread { public function __construct($loader) { $this->loader = $loader; } public function run() { $this->loader->register(); echo "</br>"; printf("Executing Thread with ZF2 Loaded (%s)\n", Debug::getSapi()); echo "<pre>"; print_r($this->loader); echo "</pre>"; } } $t = new T($loader); var_dump($t->start());
* samples - the number of times to run the test, default=5 */ /** * Nothing */ class T extends Thread { public function run() { } } $max = @$argv[1] ? $argv[1] : 1000; $sample = @$argv[2] ? $argv[2] : 5; printf("Start(%d) ...", $max); $it = 0; do { $s = microtime(true); /* begin test */ $ts = array(); while (count($ts) < $max) { $t = new T(); $t->start(); $ts[] = $t; } $ts = array(); /* end test */ $ti[] = $max / (microtime(true) - $s); printf("."); } while ($it++ < $sample); printf(" %.3f tps\n", array_sum($ti) / count($ti)); //Start(100) ......... 589.520 tps (Threads Per Second)