projects
/
m6w6
/
ext-http
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
b26ea27
)
some verbosity adjustments
author
Michael Wallner
<mike@php.net>
Thu, 10 Dec 2009 15:08:35 +0000
(15:08 +0000)
committer
Michael Wallner
<mike@php.net>
Thu, 10 Dec 2009 15:08:35 +0000
(15:08 +0000)
scripts/bench_select_vs_event.php
patch
|
blob
|
history
diff --git
a/scripts/bench_select_vs_event.php
b/scripts/bench_select_vs_event.php
index 589f31e2c2f9413dadb81b5c0bde1d542d8de595..8ae070691da23951399faa1522a514907b8ddf8a 100644
(file)
--- a/
scripts/bench_select_vs_event.php
+++ b/
scripts/bench_select_vs_event.php
@@
-4,11
+4,12
@@
class pool extends HttpRequestPool {
private $url;
private $cnt;
private $url;
private $cnt;
- static function fetch($url, $n, $c, $e) {
+ static function fetch($url, $n, $c, $e
, $p
) {
$pool = new pool;
$pool->url = $url;
$pool->cnt = $n;
$pool = new pool;
$pool->url = $url;
$pool->cnt = $n;
+ $pool->enablePipelining($p);
$pool->enableEvents($e);
for ($i = 0; $i < $c; ++$i) {
$pool->enableEvents($e);
for ($i = 0; $i < $c; ++$i) {
@@
-26,6
+27,10
@@
class pool extends HttpRequestPool {
request::init($this, $this->url)->id = $this->cnt--;
}
}
request::init($this, $this->url)->id = $this->cnt--;
}
}
+
+ function cnt() {
+ return $this->cnt;
+ }
}
class request extends HttpRequest {
}
class request extends HttpRequest {
@@
-35,6
+40,7
@@
class request extends HttpRequest {
private $pool;
static function init(pool $pool, $url) {
private $pool;
static function init(pool $pool, $url) {
+ #printf("init %d\n", $pool->cnt());
$r = new request($url);
$r->pool = $pool;
$pool->attach($r);
$r = new request($url);
$r->pool = $pool;
$pool->attach($r);
@@
-42,6
+48,8
@@
class request extends HttpRequest {
}
function onFinish() {
}
function onFinish() {
+ #printf("left %d\n", count($this->pool));
+ #printf("done %d\n", $this->id);
++self::$counter;
$this->pool->detach($this);
$this->pool->push();
++self::$counter;
$this->pool->detach($this);
$this->pool->push();
@@
-50,7
+58,7
@@
class request extends HttpRequest {
function usage() {
global $argv;
function usage() {
global $argv;
- fprintf(STDERR, "Usage: %s -u <URL> -n <requests> -c <concurrency> -e (use libevent)\n", $argv[0]);
+ fprintf(STDERR, "Usage: %s -u <URL> -n <requests> -c <concurrency> -e (use libevent)
-p (use pipelining)
\n", $argv[0]);
fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n");
exit(-1);
}
fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n");
exit(-1);
}
@@
-58,15
+66,20
@@
function usage() {
isset($argv) or $argv = $_SERVER['argv'];
defined('STDERR') or define('STDERR', fopen('php://stderr', 'w'));
isset($argv) or $argv = $_SERVER['argv'];
defined('STDERR') or define('STDERR', fopen('php://stderr', 'w'));
-$opts = getopt("u:c:n:e
"
);
+$opts = getopt("u:c:n:e
p"); #var_dump($opts
);
isset($opts["u"]) or $opts["u"] = "http://localhost/";
isset($opts["c"]) or $opts["c"] = 10;
isset($opts["u"]) or $opts["u"] = "http://localhost/";
isset($opts["c"]) or $opts["c"] = 10;
-isset($opts["n"]) or $opts["n"] =
10
00;
+isset($opts["n"]) or $opts["n"] =
5
00;
http_parse_message(http_head($opts["u"]))->responseCode == 200 or usage();
$time = microtime(true);
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"]));
+pool::fetch($opts["u"], $opts["n"], $opts["c"], isset($opts["e"])
, isset($opts["p"])
);
printf("\n> %10.6fs\n", microtime(true)-$time);
printf("\n> %10.6fs\n", microtime(true)-$time);
-request::$counter == $opts["n"] or printf("\nOnly %d finished\n", request::$counter);
+printf("\nMemory usage: %s/%s\n", number_format(memory_get_usage()),number_format(memory_get_peak_usage()));
+
+if (request::$counter != $opts["n"]) {
+ printf("\nOnly %d finished\n", request::$counter);
+ exit(1);
+}