Index: misc/httpbench.pl
===================================================================
--- misc/httpbench.pl	(revision 45d34537d0615f50c78eddbfc59a9561045e7bfc)
+++ misc/httpbench.pl	(revision 178d57852047dbd7e304480086116820b29b60f1)
@@ -17,4 +17,5 @@
     'c|concurrency=i'   => \ my $concurrency,
     'n|loops=i'         => \ my $loops,
+    'd|duration=i'      => \ my $duration,
     'w|wait=f'          => \ my $wait,
 ) or usage();
@@ -24,4 +25,5 @@
 $concurrency ||= 1;
 $loops ||= 1;
+$duration ||= 0;
 $wait ||= 0;
 
@@ -30,6 +32,7 @@
 
 my $num = scalar @urls;
-warn "$num urls with $concurrency clients, $loops loops\n";
-warn "Total: ", $num * $concurrency * $loops, " requests\n";
+my $l = ($duration) ? "$duration seconds loops" : "$loops loops";
+warn "$num urls with $concurrency clients, $l\n";
+warn "Total: ", $num * $concurrency * $loops, " requests\n" if (! $duration);
 warn "wait for $wait second between requests\n" if ($wait);
 
@@ -58,5 +61,13 @@
         # child
         my $transfer = 0;
-        for (my $i = 0; $i < $loops; $i++) {
+        my $i = 0;
+        while (1) {
+            if ($duration) {
+                last if (time() - $startsec > $duration);
+            }
+            else {
+                last if ($i >= $loops);
+            }
+            
             print STDERR "processing $i/$loops loop\r";
             foreach my $url (@urls) {
@@ -70,4 +81,6 @@
                 sleep($wait);
             }
+            
+            $i++;
         }
         $pm->finish(0, \$transfer);
