rbench 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rbench/group.rb +4 -3
- data/lib/rbench/runner.rb +2 -2
- data/spec/rbench_spec.rb +2 -2
- metadata +1 -1
data/lib/rbench/group.rb
CHANGED
@@ -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
|
31
|
+
def report(name,times=@times,&block)
|
31
32
|
@items << Report.new(@runner,self,name,times,&block)
|
32
33
|
end
|
33
34
|
|
data/lib/rbench/runner.rb
CHANGED
@@ -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)
|
data/spec/rbench_spec.rb
CHANGED
@@ -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
|
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
|
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(".") }
|