]> granicus.if.org Git - php/commitdiff
Added ability to make a number of "warmup" requests before an actual benchmark.
authorDmitry Stogov <dmitry@zend.com>
Mon, 8 Sep 2014 12:24:46 +0000 (16:24 +0400)
committerDmitry Stogov <dmitry@zend.com>
Mon, 8 Sep 2014 12:24:46 +0000 (16:24 +0400)
(php-cgi -T [<number-of-warmup-requests>,]<number-of-benchmark-requests> <file>)

sapi/cgi/cgi_main.c

index 9845d6cb74386d1f327baf8357741ab696f3b174..d73c4a3e71450c89be9cb8187e5b68510c3046c5 100644 (file)
@@ -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;