-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathHttpLoad.php
36 lines (30 loc) · 843 Bytes
/
HttpLoad.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace bench;
require __DIR__ . '/Base.php';
class HttpLoad extends Base
{
protected $http_load;
protected $http_load_file;
protected function init()
{
parent::init();
if (! file_exists($this->http_load)) {
$this->outln("File not found: '{$this->http_load}'.");
exit(1);
}
}
protected function runOnePass($href, $conc, $log_file)
{
file_put_contents($this->http_load_file, $href);
$cmd = "{$this->http_load} "
. "-parallel {$conc} "
. "-seconds {$this->seconds} "
. "{$this->http_load_file} > {$log_file}";
passthru($cmd);
}
protected function fetchReqSec($log_file)
{
$lines = file($log_file);
return (float) $lines[2];
}
}