Author: kclark
Date: Tue Jun 17 18:19:18 2008
New Revision: 669027

URL: http://svn.apache.org/viewvc?rev=669027&view=rev
Log:
rb: Fix some incorrect reporting by the benchmark.

Also make it use -J-server when jruby is the server interpreter

Modified:
    incubator/thrift/trunk/lib/rb/benchmark/benchmark.rb

Modified: incubator/thrift/trunk/lib/rb/benchmark/benchmark.rb
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/benchmark/benchmark.rb?rev=669027&r1=669026&r2=669027&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/benchmark/benchmark.rb (original)
+++ incubator/thrift/trunk/lib/rb/benchmark/benchmark.rb Tue Jun 17 18:19:18 
2008
@@ -27,7 +27,8 @@
 
   def start
     return if @serverclass == Object
-    @pipe = IO.popen("[EMAIL PROTECTED] #{File.dirname(__FILE__)}/server.rb 
[EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]", "r+")
+    args = (File.basename(@interpreter) == "jruby" ? "-J-server" : "")
+    @pipe = IO.popen("[EMAIL PROTECTED] #{args} 
#{File.dirname(__FILE__)}/server.rb [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL 
PROTECTED]", "r+")
   end
 
   def shutdown
@@ -122,6 +123,8 @@
     call_times = []
     client_times = []
     connection_failures = []
+    shortest_call = 0
+    shortest_client = 0
     longest_call = 0
     longest_client = 0
     @output.each do |logs|
@@ -136,11 +139,13 @@
           delta = time - cur_call
           call_times << delta
           longest_call = delta unless longest_call > delta
+          shortest_call = delta if shortest_call == 0 or delta < shortest_call
           cur_call = nil
         when :end
           delta = time - cur_client
           client_times << delta
           longest_client = delta unless longest_client > delta
+          shortest_client = delta if shortest_client == 0 or delta < 
shortest_client
           cur_client = nil
         when :connection_failure
           connection_failures << time
@@ -153,6 +158,8 @@
     @report[:total_clients] = client_times.inject(0.0) { |a,t| a += t }
     @report[:avg_clients] = @report[:total_clients] / client_times.size
     @report[:connection_failures] = connection_failures.size
+    @report[:shortest_call] = shortest_call
+    @report[:shortest_client] = shortest_client
     @report[:longest_call] = longest_call
     @report[:longest_client] = longest_client
     @report[:total_benchmark_time] = @benchmark_end - @benchmark_start
@@ -179,7 +186,9 @@
              ["Average time per client (%d calls)" % @calls_per_client, 
@report[:avg_clients]],
              ["Total time for all calls", @report[:total_calls]],
              ["Real time for benchmarking", @report[:total_benchmark_time]],
-             ["Shortest call time", @report[:longest_call]],
+             ["Shortest call time", @report[:shortest_call]],
+             ["Longest call time", @report[:longest_call]],
+             ["Shortest client time (%d calls)" % @calls_per_client, 
@report[:shortest_client]],
              ["Longest client time (%d calls)" % @calls_per_client, 
@report[:longest_client]]
   end
 


Reply via email to