From: Dmitry Stogov Date: Mon, 8 Sep 2014 12:24:46 +0000 (+0400) Subject: Added ability to make a number of "warmup" requests before an actual benchmark. X-Git-Tag: PRE_PHP7_REMOVALS~98 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6561d03a41772309aaff6027dced8b349eaf1458;p=php Added ability to make a number of "warmup" requests before an actual benchmark. (php-cgi -T [,] ) --- diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 9845d6cb74..d73c4a3e71 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;