rbench 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,13 +4,14 @@ module RBench
4
4
  send(:undef_method, m) unless m =~ /^(__|is_a?|kind_of?|respond_to?|hash|eql?|inspect|instance_eval)/
5
5
  end
6
6
 
7
- attr_reader :name, :items, :block
7
+ attr_reader :name, :items, :block, :times
8
8
 
9
- def initialize(runner, name, &block)
9
+ def initialize(runner, name, times=nil, &block)
10
10
  @runner = runner
11
11
  @name = name
12
12
  @items = []
13
13
  @block = block
14
+ @times = times || @runner.times
14
15
  end
15
16
 
16
17
  def prepare
@@ -27,7 +28,7 @@ module RBench
27
28
  @items.each{|item| item.run}
28
29
  end
29
30
 
30
- def report(name,times=nil,&block)
31
+ def report(name,times=@times,&block)
31
32
  @items << Report.new(@runner,self,name,times,&block)
32
33
  end
33
34
 
@@ -43,8 +43,8 @@ module RBench
43
43
  @columns << Column.new(self,name,options)
44
44
  end
45
45
 
46
- def group(name,&block)
47
- @items << Group.new(self,name,&block)
46
+ def group(name,times=nil,&block)
47
+ @items << Group.new(self,name,times,&block)
48
48
  end
49
49
 
50
50
  def report(name,times=nil,&block)
@@ -114,7 +114,7 @@ RBench.run(TIMES) do
114
114
  column :two, :title => "#2"
115
115
  column :diff, :title => "#1/#2", :compare => [:one,:two]
116
116
 
117
- group("Squeezing") do
117
+ group "Squeezing", 10000 do
118
118
  report "with #squeeze" do
119
119
  one { "abc//def//ghi//jkl".squeeze("/") }
120
120
  two { "abc///def///ghi///jkl".squeeze("/") }
@@ -127,7 +127,7 @@ RBench.run(TIMES) do
127
127
  summary "all methods (totals)"
128
128
  end
129
129
 
130
- group("Splitting") do
130
+ group "Splitting" do
131
131
  report "with #split" do
132
132
  one { "aaa/aaa/aaa.bbb.ccc.ddd".split(".") }
133
133
  two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".split(".") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz & Sindre Aarsaether