Skip to content

Commit 07d3f44

Browse files
committed
Add composer.json; fix typos in comments; remove unused code
1 parent 706eeed commit 07d3f44

File tree

8 files changed

+91
-48
lines changed

8 files changed

+91
-48
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.gitattributes export-ignore
2+
.gitignore export-ignore

README_ezab.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ Some features of the original AB are still missing, such as POST/PUT support, et
4747
The output of the tool is also lacking.
4848
Instead of having the list of things that do work in the docs, it is suggested to run the script with the -h option.
4949

50-
On the other hand, there are already a couple of fetaures that we do better than the original:
50+
On the other hand, there are already a couple of features that we do better than the original:
5151
1. support for http 1.1 by default. AB uses http 1.0, but most of the web in 2012 runs on version 1.1.
5252
This means that the numbers you get should be closer to "real life traffic"
53-
2. better support for keepalives (AB can only do http/1.0 keepalives, which Apache does not support when running dynamic page generators such as php)
53+
2. better support for keep-alives (AB can only do http/1.0 keepalives, which Apache does not support when running dynamic page generators such as php)
5454
3. easy support for compressed http responses (using the -j option)
5555

5656

@@ -60,6 +60,6 @@ Under the hood
6060
Whatever way you choose to run the program, what happens is that the php script will
6161
execute more copies of itself, each of which will send some requests to the server.
6262
The number of processes forked depends on the "-c" parameter.
63-
The main process waits for all chidren to terminate execution, collects their
63+
The main process waits for all children to terminate execution, collects their
6464
metrics, aggregates them and displays the result.
6565
To debug execution of the program if anything goes wrong, run it at verbosity level 4 (option: -v 4)

README_ezmyreplay.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a tool for benchmarking MySql database servers.
55
It is designed to give you an impression of how your current database server
66
installation performs, by repeatedly executing - with many parallel threads - a
77
series of queries taken from a file.
8-
There is no need to have a spoecific database schema or data-set installed.
8+
There is no need to have a specific database schema or data-set installed.
99
It is inspired by the percona-playback tool from Percona.
1010

1111

@@ -63,7 +63,7 @@ To get a full list of supported options run the script using the -h option:
6363

6464
Notes:
6565
. you can omit from command line arguments to specify the database to use if there
66-
are USE statements in your sql log. Viceversa USE statements in your sql log
66+
are USE statements in your sql log. Vice-versa USE statements in your sql log
6767
will be ignored if you specify on the command line a database to be used
6868

6969

@@ -86,11 +86,11 @@ Under the hood
8686
Whatever way you choose to run the program, what happens is that the php script will
8787
execute more copies of itself, each of which will send some requests to the server.
8888
The number of processes forked depends on the "-c" parameter.
89-
The main process waits for all chidren to terminate execution, collects their
89+
The main process waits for all children to terminate execution, collects their
9090
metrics, aggregates them and displays the result.
9191
To debug execution of the program if anything goes wrong, run it at verbosity level 4 (option: -v 4)
9292

9393
The sql log to be replayed is parsed once, and saved to a temporary file in json format.
9494
If your log takes a long time in parsing, you can make the benchmarking process
9595
faster by saving it in parsed form, using the "--dump" option, and later load
96-
it by using "--format json"
96+
it by using "--format json"

abrunner.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @author G. Giunta
1111
* @license GNU GPL 2.0
12-
* @copyright (C) G. Giunta 2012
12+
* @copyright (C) G. Giunta 2012-2019
1313
*
1414
* @todo add more cli options: verbosity
1515
* @todo AB only does http 1.0 requests; it would be nice to use siege, which can do http 1.1 - workaround: use ezab.php
@@ -28,14 +28,14 @@
2828
{
2929
die( "Sorry, web interface not yet developed..." );
3030
// parse options in array format (die with help msg if needed)
31-
$ab->parseOpts( $_GET );
31+
//$ab->parseOpts( $_GET );
3232
}
3333
$ab->run();
3434
}
3535

3636
class ABRunner
3737
{
38-
static $version = '0.1-dev';
38+
static $version = '0.1';
3939
static $defaults = array(
4040
// 'real' options
4141
'label' => '',
@@ -75,29 +75,34 @@ function __construct( $opts = array() )
7575
/**
7676
* Actual execution of the test
7777
* Depending on options, calls runTests or echoes help messages
78+
* @throws Exception
7879
*/
7980
public function run()
8081
{
8182
switch ( $this->opts['command'] )
8283
{
8384
case 'runtests':
84-
return $this->runTests();
85+
$this->runTests();
86+
return;
8587
case 'versionmsg':
8688
echo $this->versionMsg();
8789
break;
8890
case 'helpmsg':
8991
echo $this->helpMsg();
9092
break;
9193
default:
92-
$this->abort( 1 , 'Unkown running mode: ' . $this->opts['command'] );
94+
$this->abort( 1 , 'Unknown running mode: ' . $this->opts['command'] );
9395
}
9496
}
9597

98+
/**
99+
* @throws Exception
100+
*/
96101
public function runTests()
97102
{
98103
$opts = $this->opts;
99104

100-
$outfile = $opts['output_dir'] . '/' . $opts['summary_file'];
105+
//$outfile = $opts['output_dir'] . '/' . $opts['summary_file'];
101106
if ( !is_dir( $opts['output_dir'] ) )
102107
{
103108
mkdir( $opts['output_dir'] ) || $this->abort( 1, "can not create directory for output: {$opts['output_dir']}" );
@@ -295,9 +300,13 @@ protected function runABTest( $ab, $url, $concurrency, $logfilename, $aggfilenam
295300
}
296301
}
297302

303+
/**
304+
* @param string $ab
305+
* @return string
306+
* @throws Exception
307+
*/
298308
protected function getABExecutable( $ab='ab' )
299309
{
300-
$validExecutable = false;
301310
do
302311
{
303312
$output = array();
@@ -324,7 +333,8 @@ protected function getABExecutable( $ab='ab' )
324333
/**
325334
* Parses args in argc/argv format (stores them, unless -h or -V are found, in which case only $this->opts['self'] is set)
326335
* If any unknown option is found, prints help msg and exit.
327-
* Nb: pre-existing otions are not reset by this call.
336+
* Nb: pre-existing options are not reset by this call.
337+
* @throws Exception
328338
*/
329339
public function parseArgs( $argv )
330340
{
@@ -532,15 +542,15 @@ function versionMsg( $forceplaintext=false )
532542
if ( $this->opts['outputformat'] == 'html' && !$forceplaintext )
533543
$out .= '<pre>';
534544
$out .= "This is ABRunner, Version " . self::$version . "\n";
535-
$out .= "Copyright 2012 G. Giunta, eZ Systems, http://ez.no\n";
545+
$out .= "Copyright 2012-2019 G. Giunta, eZ Systems, http://ez.no\n";
536546
if ( $this->opts['outputformat'] == 'html' && !$forceplaintext )
537547
$out .= '</pre>';
538548
return $out;
539549
}
540550

541551
/**
542552
* Either exits or throws an exception
543-
*
553+
* @throws Exception
544554
* @todo !important when in web mode, there is little sign that there was an error...
545555
*/
546556
protected function abort( $errcode=1, $msg='' )
@@ -570,4 +580,4 @@ protected function abort( $errcode=1, $msg='' )
570580
}
571581
}
572582

573-
?>
583+
?>

composer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "gggeek/ezab",
3+
"description": "A suite of tools for benchmarking (load testing) web servers and databases",
4+
"keywords": ["automation", "build", "task"],
5+
"license": "GPL-2.0",
6+
"require": {
7+
"php": ">=5",
8+
"ext-curl": "*"
9+
},
10+
"bin": ["abrunner.php", "ezab.php", "ezmyreplay.php"]
11+
}

ezab.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author G. Giunta
66
* @license GNU GPL 2.0
7-
* @copyright (C) G. Giunta 2010-2012
7+
* @copyright (C) G. Giunta 2010-2019
88
*
99
* It uses curl for executing the http requests.
1010
* It uses a multi-process scheme (tested to be working both on windows and linux):
@@ -27,7 +27,7 @@
2727

2828
if ( !defined( 'EZAB_AS_LIB' ) )
2929
{
30-
if( !function_exists( 'curl_init' ) )
30+
if ( !function_exists( 'curl_init' ) )
3131
{
3232
echo( 'Missing cURL, cannot run' );
3333
exit( 1 );
@@ -50,16 +50,16 @@
5050

5151
class eZAB
5252
{
53-
static $version = '0.3-dev';
53+
static $version = '0.3';
5454
static $defaults = array(
5555
// 'real' options
5656
/// How much troubleshooting info to print. According to ab docs:
5757
/// "4 and above prints information on headers, 3 and above prints response codes (404, 200, etc.), 2 and above prints warnings and info."
5858
/// Real life testing seem to tell a different story though...
5959
'verbosity' => 1, // -v verbosity
6060
'children' => 1, // -c concurrency Number of multiple requests to make
61-
'tries' => 1, // -n requests Number of requests to perform
62-
'timeout' => 0, // -t timelimit Seconds to max. wait for responses
61+
'tries' => 1, // -n requests Number of requests to perform
62+
'timeout' => 0, // -t timelimit Seconds to max. wait for responses
6363
'auth' => false,
6464
'proxy' => false,
6565
'proxyauth' => false,
@@ -97,6 +97,7 @@ function __construct( $opts = array() )
9797
/**
9898
* Actual execution of the test, echoes results to stdout.
9999
* Depending on options, calls runParent or runChild, or echoes help messages
100+
* @throws Exception
100101
*/
101102
public function run()
102103
{
@@ -114,14 +115,15 @@ public function run()
114115
echo $this->helpMsg();
115116
break;
116117
default:
117-
$this->abort( 1 , 'Unkown running mode: ' . $this->opts['command'] );
118+
$this->abort( 1 , 'Unknown running mode: ' . $this->opts['command'] );
118119
}
119120
}
120121

121122
/**
122123
* Runs the test, prints results (unless verbosity option has been set to 0).
123124
* Note: sets a value to $this->opts['parentid'], too
124125
* @return array
126+
* @throws Exception
125127
*/
126128
public function runParent()
127129
{
@@ -207,7 +209,7 @@ public function runParent()
207209
//$starttimes = array();
208210
$pipes = array();
209211
$childprocs = array();
210-
$childresults = array();
212+
//$childresults = array();
211213

212214
//$time = microtime( true );
213215

@@ -241,7 +243,7 @@ public function runParent()
241243
// wait for all children to finish
242244
/// @todo add a global timeout limit?
243245
$finished = 0;
244-
$outputs = array();
246+
//$outputs = array();
245247
do
246248
{
247249
/// @todo !important lower this - use usleep
@@ -423,7 +425,7 @@ public function runChild()
423425
if ( $curl )
424426
{
425427
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
426-
// enbale receiving header too. We will need later to split by ourselves headers from body to calculate correct sizes
428+
// enable receiving header too. We will need later to split by ourselves headers from body to calculate correct sizes
427429
curl_setopt( $curl, CURLOPT_HEADER, true );
428430
curl_setopt( $curl, CURLOPT_USERAGENT, "eZAB " . self::$version );
429431
if ( $opts['timeout'] > 0 )
@@ -578,7 +580,7 @@ public function runChild()
578580
}
579581

580582
/**
581-
* Parse the ouput of children processes and calculate global stats
583+
* Parse the output of children processes and calculate global stats
582584
*/
583585
protected function parseOutputs( $outputs )
584586
{
@@ -692,9 +694,13 @@ protected function parseOutputs( $outputs )
692694
return $resp;
693695
}
694696

697+
/**
698+
* @param string $php
699+
* @return string
700+
* @throws Exception
701+
*/
695702
protected function getPHPExecutable( $php='php' )
696703
{
697-
$validExecutable = false;
698704
do
699705
{
700706
$output = array();
@@ -721,7 +727,8 @@ protected function getPHPExecutable( $php='php' )
721727
/**
722728
* Parses args in argc/argv format (stores them, unless -h or -V are found, in which case only $this->opts['self'] is set)
723729
* If any unknown option is found, prints help msg and exit.
724-
* Nb: pre-existing otions are not reset by this call.
730+
* Nb: pre-existing options are not reset by this call.
731+
* @throws Exception
725732
*/
726733
public function parseArgs( $argv )
727734
{
@@ -812,10 +819,10 @@ public function parseArgs( $argv )
812819
$opts['childnr'] = (int)$val;
813820
$opts['command'] = 'runchild';
814821
break;
815-
case 'i':
822+
case 'i':
816823
$opts['head'] = true;
817824
break;
818-
case 'j':
825+
case 'j':
819826
$opts['respencoding'] = true;
820827
break;
821828
case 'k':
@@ -1037,15 +1044,15 @@ function versionMsg()
10371044
if ( $this->opts['outputformat'] == 'html' )
10381045
$out .= '<pre>';
10391046
$out .= "This is eZAB, Version " . self::$version . "\n";
1040-
$out .= "Copyright 2010-2012 G. Giunta, eZ Systems, http://ez.no\n";
1047+
$out .= "Copyright 2010-2019 G. Giunta, eZ Systems, http://ez.no\n";
10411048
if ( $this->opts['outputformat'] == 'html' )
10421049
$out .= '</pre>';
10431050
return $out;
10441051
}
10451052

10461053
/**
10471054
* Either exits or throws an exception
1048-
*
1055+
* @throws Exception
10491056
* @todo !important when in web mode, there is little sign that there was an error...
10501057
*/
10511058
protected function abort( $errcode=1, $msg='' )
@@ -1074,5 +1081,3 @@ protected function abort( $errcode=1, $msg='' )
10741081
}
10751082
}
10761083
}
1077-
1078-
?>

0 commit comments

Comments
 (0)