X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=scripts%2Fbench_select_vs_event.php;fp=scripts%2Fbench_select_vs_event.php;h=0000000000000000000000000000000000000000;hp=589f31e2c2f9413dadb81b5c0bde1d542d8de595;hb=87db9817d428282792c8146d9c2ae9748ebf6f1e;hpb=7a5c865f6faf8b1b6c91735e9d3b040449ea74ba diff --git a/scripts/bench_select_vs_event.php b/scripts/bench_select_vs_event.php deleted file mode 100644 index 589f31e..0000000 --- a/scripts/bench_select_vs_event.php +++ /dev/null @@ -1,72 +0,0 @@ -url = $url; - $pool->cnt = $n; - - $pool->enableEvents($e); - - for ($i = 0; $i < $c; ++$i) { - $pool->push(); - } - try { - $pool->send(); - } catch (Exception $ex) { - echo $ex, "\n"; - } - } - - function push() { - if ($this->cnt > 0) { - request::init($this, $this->url)->id = $this->cnt--; - } - } -} - -class request extends HttpRequest { - static $counter = 0; - - public $id; - private $pool; - - static function init(pool $pool, $url) { - $r = new request($url); - $r->pool = $pool; - $pool->attach($r); - return $r; - } - - function onFinish() { - ++self::$counter; - $this->pool->detach($this); - $this->pool->push(); - } -} - -function usage() { - global $argv; - fprintf(STDERR, "Usage: %s -u -n -c -e (use libevent)\n", $argv[0]); - fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n"); - exit(-1); -} - -isset($argv) or $argv = $_SERVER['argv']; -defined('STDERR') or define('STDERR', fopen('php://stderr', 'w')); - -$opts = getopt("u:c:n:e"); -isset($opts["u"]) or $opts["u"] = "http://localhost/"; -isset($opts["c"]) or $opts["c"] = 10; -isset($opts["n"]) or $opts["n"] = 1000; - -http_parse_message(http_head($opts["u"]))->responseCode == 200 or usage(); - -$time = microtime(true); -pool::fetch($opts["u"], $opts["n"], $opts["c"], isset($opts["e"])); -printf("\n> %10.6fs\n", microtime(true)-$time); - -request::$counter == $opts["n"] or printf("\nOnly %d finished\n", request::$counter);