com php-src: Added ability to make a number of "warmup" requests before an actual benchmark. (php-cgi -T
[<number-of-warmup-requests>,]<number-of-benchmark-requests> <file>): sapi/cgi/cgi_main.c
| From: | Dmitry Stogov | Date: | Mon, 08 Sep 2014 12:24:46 +0000 |
| Subject: | com php-src: Added ability to make a number of "warmup" requests before an actual benchmark. (php-cgi -T [<number-of-warmup-requests>,]<number-of-benchmark-requests> <file>): sapi/cgi/cgi_main.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81455@lists.php.net to get a copy of this message | ||
Commit: 6561d03a41772309aaff6027dced8b349eaf1458
Author: Dmitry Stogov <dmitry@zend.com> Mon, 8 Sep 2014 16:24:46 +0400
Parents: af84d5737c47c3ec3959e056f171b14ab76fb7b8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6561d03a41772309aaff6027dced8b349eaf1458
Log:
Added ability to make a number of "warmup" requests before an actual benchmark.
(php-cgi -T [<number-of-warmup-requests>,]<number-of-benchmark-requests> <file>)
Changed paths:
M sapi/cgi/cgi_main.c
Diff:
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 9845d6c..d73c4a3 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1751,6 +1751,7 @@ int main(int argc, char *argv[])
char *bindpath = NULL;
int fcgi_fd = 0;
fcgi_request *request = NULL;
+ int warmup_repeats = 0;
int repeats = 1;
int benchmark = 0;
#if HAVE_GETTIMEOFDAY
@@ -2094,7 +2095,15 @@ consult the installation file that came with this distribution, or visit \n\
switch (c) {
case 'T':
benchmark = 1;
- repeats = atoi(php_optarg);
+ {
+ char *comma = strchr(php_optarg, ',');
+ if (comma) {
+ warmup_repeats = atoi(php_optarg);
+ repeats = atoi(comma + 1);
+ } else {
+ repeats = atoi(php_optarg);
+ }
+ }
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&start, NULL);
#else
@@ -2512,12 +2521,24 @@ fastcgi_request_done:
if (!fastcgi) {
if (benchmark) {
- repeats--;
- if (repeats > 0) {
- script_file = NULL;
- php_optind = orig_optind;
- php_optarg = orig_optarg;
+ if (warmup_repeats) {
+ warmup_repeats--;
+ if (!warmup_repeats) {
+#ifdef HAVE_GETTIMEOFDAY
+ gettimeofday(&start, NULL);
+#else
+ time(&start);
+#endif
+ }
continue;
+ } else {
+ repeats--;
+ if (repeats > 0) {
+ script_file = NULL;
+ php_optind = orig_optind;
+ php_optarg = orig_optarg;
+ continue;
+ }
}
}
break;