[Groonga-commit] droonga/http-benchmark at 72f1856 [master] Extract codes to output benchmark result to "Formatter" class

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Oct 7 18:04:27 JST 2013


YUKI Hiroshi	2013-10-07 18:04:27 +0900 (Mon, 07 Oct 2013)

  New Revision: 72f18569018fda950a995d355d3230f8bef05dba
  https://github.com/droonga/http-benchmark/commit/72f18569018fda950a995d355d3230f8bef05dba

  Message:
    Extract codes to output benchmark result to "Formatter" class

  Added files:
    lib/droonga/http-benchmark/formatter.rb
  Modified files:
    lib/droonga/http-benchmark.rb
    lib/droonga/http-benchmark/runner.rb

  Modified: lib/droonga/http-benchmark.rb (+1 -0)
===================================================================
--- lib/droonga/http-benchmark.rb    2013-10-07 17:59:02 +0900 (c2a2e12)
+++ lib/droonga/http-benchmark.rb    2013-10-07 18:04:27 +0900 (1fbcbf0)
@@ -1,3 +1,4 @@
 # -*- coding: utf-8 -*-
 
 require "http-benchmark/runner"
+require "http-benchmark/formatter"

  Added: lib/droonga/http-benchmark/formatter.rb (+22 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/http-benchmark/formatter.rb    2013-10-07 18:04:27 +0900 (df32dff)
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+module Droonga
+  module HttpBenchmark
+    class Formatter
+      class << self
+        def output_one_result(result)I
+          puts "Total requests: #{result[:total_n_requests]} " +
+                 "(#{result[:queries_per_second]} queries per second)"
+          puts "Status:"
+          result[:responses].each do |status, percentage|
+            puts "  #{status}: #{percentage} %"
+          end
+          puts "Elapsed time:"
+          puts "  min:     #{result[:min_elapsed_time} sec"
+          puts "  max:     #{result[:max_elapsed_time} sec"
+          puts "  average: #{result[:average_elapsed_time]} sec"
+        end
+      end
+    end
+  end
+end

  Modified: lib/droonga/http-benchmark/runner.rb (+2 -14)
===================================================================
--- lib/droonga/http-benchmark/runner.rb    2013-10-07 17:59:02 +0900 (215cdc5)
+++ lib/droonga/http-benchmark/runner.rb    2013-10-07 18:04:27 +0900 (439d5b8)
@@ -3,6 +3,7 @@
 require "thread"
 require "net/http"
 require "json"
+require "./formatter"
 
 module Droonga
   module HttpBenchmark
@@ -45,7 +46,7 @@ module Droonga
       def run
         process_requests
         analyze_results
-        output_result
+        Formatter.output_one_result(@result)
         @result
       end
 
@@ -148,19 +149,6 @@ module Droonga
         }
       end
 
-      def output_result
-        puts "Total requests: #{@result[:total_n_requests]} " +
-               "(#{@result[:queries_per_second]} queries per second)"
-        puts "Status:"
-        @result[:responses].each do |status, percentage|
-          puts "  #{status}: #{percentage} %"
-        end
-        puts "Elapsed time:"
-        puts "  min:     #{@result[:min_elapsed_time} sec"
-        puts "  max:     #{@result[:max_elapsed_time} sec"
-        puts "  average: #{@result[:average_elapsed_time]} sec"
-      end
-
       def populate_requests
         @requests = []
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index