[Groonga-commit] droonga/http-benchmark at f1695a5 [master] Output result of GradualRunner as a CSV

アーカイブの一覧に戻る

YUKI Hiroshi yuki****@clear*****
Mon Oct 7 18:53:31 JST 2013


情報ありがとうございます。
しかし、やってみたんですが、ハッシュのキーが長いのであんまり綺麗になった 
気がしなかったというオチでした……

Kenji Okimoto wrote:
> On 2013年10月07日 18:15, YUKI Hiroshi wrote:
>> Author
>>      YUKI Hiroshi <shimoda �� clear-code.com>
>> Date
>>      2013-10-07 18:15:30 +0900 (Mon, 07 Oct 2013)
>> New Revision
>>      f1695a5d4f2c8be722383e3e5ecee5cb6f9668e9 <https://github.com/droonga/http-benchmark/commit/f1695a5d4f2c8be722383e3e5ecee5cb6f9668e9>
>> Message
>>
>>      Output result of GradualRunner as a CSV
>>
>> Modified files
>>
>>        * lib/droonga/http-benchmark/formatter.rb <https://github.com/droonga/http-benchmark/commit/f1695a5d4f2c8be722383e3e5ecee5cb6f9668e9#diff-0>
>>        * lib/droonga/http-benchmark/gradual-runner.rb <https://github.com/droonga/http-benchmark/commit/f1695a5d4f2c8be722383e3e5ecee5cb6f9668e9#diff-1>
>>
>>     Modified: lib/droonga/http-benchmark/formatter.rb (+29 -0)
>> ===================================================================
>>
>>
>> @@ -16,6 +16,35 @@module Droonga
>>              puts "  max:     #{result[:max_elapsed_time} sec"
>>              puts "  average: #{result[:average_elapsed_time]} sec"
>>            end
>> +
>> +        def output_gradual_results(results)
>> +          http_statuses = []
>> +          results.each do |n_clients, result|
>> +            http_statuses += result[:responses].keys
>> +          end
>> +          http_statuses.uniq!
>> +          http_statuses.sort!
>> +
>> +          puts "n_clients,total_n_requests,queries_per_second," +
>> +                 "#{http_statuses.join(",")}," +
>> +                 "min_elapsed_time,max_elapsed_time,average_elapsed_time"
>> +          results.each do |n_clients, result|
>> +            response_statuses = http_statuses.collect do |status|
>> +              if result[:responses].include?(status)
>> +                result[:responses][status]
>> +              else
>> +                0
>> +              end
>> +            end
>> +            puts "#{n_clients}," +
>> +                   "#{result[:total_n_requests]}," +
>> +                   "#{result[:queries_per_second]}," +
>> +                   "#{response_statuses.join(",")}," +
>> +                   "#{result[:min_elapsed_time]}," +
>> +                   "#{result[:max_elapsed_time]}," +
>> +                   "#{result[:average_elapsed_time]},"
>> +          end
>> +        end
>>          end
>
> 一行にたくさんの変数を埋め込むときは String#% を使うときれいに書けることがありますよ。
>
> "%d,%f,%s,%d,%d,%f" % [...]
>
> http://doc.ruby-lang.org/ja/2.0.0/method/String/i/=25.html
>
> 全部ハッシュになってるなら↑の一番下にある名前を付ける方法が使えます。
>
>
>>        end
>>      end
>>
>>     Modified: lib/droonga/http-benchmark/gradual-runner.rb (+11 -2)
>> ===================================================================
>>
>> 	
>>
>> @@ -11,10 +11,19 @@module Droonga
>>            @start_n_clients = params[:start_n_clients]
>>            @end_n_clients = params[:end_n_clients]
>>            @step = params[:step]
>> -        @results = []
>> +      end
>> +
>> +      def run
>> +        run_benchmarks
>> +        Formatter.output_gradual_results(@results)
>> +      end
>> +
>> +      private
>> +      def run_benchmarks
>> +        @results = {}
>>            @start_n_clients.step(@end_n_clients, @step) do |n_clients|
>>              benchmark = Runner.new(params.merge(:n_clients => n_clients))
>> -          @results << benchmark.run
>> +          @results[n_clients] = benchmark.run
>>            end
>>          end
>>        end
>>
>>
>>
>> _______________________________________________
>> Groonga-commit mailing list
>> Groonga-commit �� lists.sourceforge.jp
>> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit
>>
>
>

-- 
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com

株式会社クリアコード
〒113-0033 東京都文京区本郷3-27-12
            本郷デントビル2階
TEL : 03-6231-7270
FAX : 03-6231-7271
WWW : http://www.clear-code.com/




More information about the Groonga-commit mailing list
アーカイブの一覧に戻る