[Groonga-commit] droonga/http-benchmark at 14abe56 [master] Add skelton

Back to archive index

YUKI Hiroshi yuki****@clear*****
Mon Oct 7 15:24:36 JST 2013


これは知らなかったか失念しておりました。ありがとうございます。
他のプロジェクトの物も併せて、その機能を使うように直しました。

Kenji Okimoto wrote:
> On 2013年10月07日 14:59, YUKI Hiroshi wrote:
>> Author
>>      YUKI Hiroshi <shimoda �� clear-code.com>
>> Date
>>      2013-10-07 14:59:13 +0900 (Mon, 07 Oct 2013)
>> New Revision
>>      14abe56b9e7cce01cb6029576efda00d39871e69 <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69>
>> Message
>>
>>      Add skelton
>
>   > +  parser.on("--duration=SECONDS",
>   > +            "duration of the benmark") do |duration|
>   > +    options[:duration] = duration.to_f
>   > +  end
>
> parser.on("--duration=SECONDS", Float,
>             "duration of the benmark") do |duration|
>     options[:duration] = duration
> end
>
>   > +  parser.on("--threads=COUNT",
>   > +            "count of threads") do |threads|
>   > +    options[:threads] = threads.to_i
>   > +  end
>
> parser.on("--threads=COUNT", Integer,
>             "count of threads") do |threads|
>     options[:threads] = threads
> end
>
> みたいに、型変換を指定して書くことができます。
>
> あと、この書き方で引数は必須になっているので --duration とかを省略するとたぶん
> option_parser.parse!(ARGV)
> した時点でエラーになる気がします。
>
> https://github.com/milter-manager/milter-manager/blob/master/tool/milter-performance-check
>
>
>
>>
>> Added files
>>
>>        * bin/http-benchmark <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#diff-0>
>>        * lib/droonga/http-benchmark.rb <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#diff-1>
>>
>>     Added: bin/http-benchmark (+29 -0) 100755
>> ===================================================================
>>
>> @@ -0,0 +1,29 @@
>> +#!/usr/bin/env ruby
>> +# -*- coding: utf-8 -*-
>> +
>> +require "droonga/http-benchmark"
>> +require "optparse"
>> +
>> +options = {}
>> +option_parser = OptionParser.new do |parser|
>> +  parser.on("--duration=SECONDS",
>> +            "duration of the benmark") do |duration|
>> +    options[:duration] = duration.to_f
>> +  end
>> +  parser.on("--threads=COUNT",
>> +            "count of threads") do |threads|
>> +    options[:threads] = threads.to_i
>> +  end
>> +end
>> +args = option_parser.parse!(ARGV)
>> +
>> +if options[:duration].nil?
>> +  raise "You must specify the test duration by --duration option."
>> +end
>> +if options[:threads].nil?
>> +  raise "You must specify the count of request threads by --threads option."
>> +end
>> +
>> +benchmark = Droonga::HttpBenchmark.new(:duration => options[:duration],
>> +                                       :threads_count => options[:threads])
>> +benchmark.run
>>
>>     Added: lib/droonga/http-benchmark.rb (+17 -0) 100644
>> ===================================================================
>>
>> ...  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1L-1>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 	
>>
>> ...  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R0>
>> 1  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R1>
>> 2  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R2>
>> 3  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R3>
>> 4  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R4>
>> 5  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R5>
>> 6  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R6>
>> 7  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R7>
>> 8  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R8>
>> 9  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R9>
>> 10  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R10>
>> 11  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R11>
>> 12  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R12>
>> 13  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R13>
>> 14  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R14>
>> 15  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R15>
>> 16  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R16>
>> 17  <https://github.com/droonga/http-benchmark/commit/14abe56b9e7cce01cb6029576efda00d39871e69#L1R17>
>>
>> 	
>>
>> @@ -0,0 +1,17 @@
>> +# -*- coding: utf-8 -*-
>> +
>> +class HttpBenchmark
>> +  attr_reader :duration, :threads_count
>> +
>> +  MIN_DURATION = 1.0
>> +  MAX_THREADS_COUNT = 16
>> +
>> +  def initialize(params)
>> +    @duration = [params[:duration], MIN_DURATION].max
>> +    @threads_count = [params[:threads_count], MAX_THREADS_COUNT].min
>> +  end
>> +
>> +  def run
>> +    raise "not implemented"
>> +  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
Back to archive index