rubyperf 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/perf/meter.rb +1 -1
- data/lib/perf/report_format.rb +10 -3
- data/rubyperf.gemspec +1 -1
- data/test/test_perf_meter.rb +22 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.5
|
data/lib/perf/meter.rb
CHANGED
@@ -320,7 +320,7 @@ module Perf
|
|
320
320
|
over=@@overhead.total+@@overhead.real
|
321
321
|
if over>0 && @@overhead.total>=0 && @@overhead.real>=0
|
322
322
|
m=get_measurement(path)
|
323
|
-
if m.count>0 && m.time.total
|
323
|
+
if m.count>0 && (m.time.total+m.time.real)>0
|
324
324
|
return (m.time.total+m.time.real) / (over*m.count)
|
325
325
|
end
|
326
326
|
end
|
data/lib/perf/report_format.rb
CHANGED
@@ -24,11 +24,15 @@ module Perf
|
|
24
24
|
# ==== Options
|
25
25
|
#
|
26
26
|
# * +:max_count_len+ : Maximum expected length of a block/espresson/method count.
|
27
|
+
# * +filter_below_accuracy+ : Minimum accuracy to report the measure; floating point value; default=nil (all)
|
28
|
+
# * +filter_below_percent+ : Minimum percent to report the measure; floating point value; default=nil (all)
|
27
29
|
#
|
28
30
|
|
29
31
|
def format(perf,options={})
|
30
32
|
options||={}
|
31
33
|
options[:max_count_len] ||= 6
|
34
|
+
options[:filter_below_accuracy] ||= nil
|
35
|
+
options[:filter_below_percent] ||= nil
|
32
36
|
rep=[]
|
33
37
|
percents={}
|
34
38
|
|
@@ -77,13 +81,16 @@ module Perf
|
|
77
81
|
|
78
82
|
# Split of keys
|
79
83
|
keys_in_order.each do |what|
|
84
|
+
next if options[:filter_below_percent] && percents[what]<options[:filter_below_percent]
|
80
85
|
m=perf.measurements[what]
|
86
|
+
accuracy = perf.accuracy(m.path)
|
87
|
+
next if options[:filter_below_accuracy] && accuracy<options[:filter_below_accuracy]
|
81
88
|
title = format_title(what,options)
|
82
|
-
rep << format_measure(:title => title,
|
89
|
+
rep << format_measure(:title => title, :max_title => max_title,
|
83
90
|
:percent => percents[what]||0.0,
|
84
|
-
:count => m.count,
|
91
|
+
:count => m.count, :max_count => max_count,
|
85
92
|
:time => m.time,
|
86
|
-
:accuracy => format_accuracy(
|
93
|
+
:accuracy => format_accuracy(accuracy), :max_accuracy => MAX_ACCURACY_SIZE,
|
87
94
|
:options => options)
|
88
95
|
end
|
89
96
|
|
data/rubyperf.gemspec
CHANGED
data/test/test_perf_meter.rb
CHANGED
@@ -134,6 +134,28 @@ class TestPerfMeter < Test::Unit::TestCase
|
|
134
134
|
assert m.accuracy(m.measurements['\blocks'].path) >= 0
|
135
135
|
assert m.accuracy(m.measurements['\blocks\a'].path) >= 0
|
136
136
|
assert m.accuracy(m.measurements['\blocks\b'].path) < 0
|
137
|
+
assert_equal 2,m.report_list_of_measures(:filter_below_accuracy=>0.0001).length
|
138
|
+
assert_equal 2,m.report_list_of_measures(:filter_below_percent=>1).length
|
139
|
+
assert_equal 3,m.report_list_of_measures(:filter_below_accuracy=>-10).length
|
140
|
+
assert_equal 3,m.report_list_of_measures(:filter_below_percent=>-10).length
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_filters
|
144
|
+
m=Perf::Meter.new
|
145
|
+
m.measure(:a) do
|
146
|
+
sleep(0.2)
|
147
|
+
end
|
148
|
+
m.measure(:b) do
|
149
|
+
sleep(0.1)
|
150
|
+
end
|
151
|
+
m.measure(:c) do
|
152
|
+
sleep(0.0001)
|
153
|
+
end
|
154
|
+
assert_equal 4,m.report_list_of_measures.length
|
155
|
+
assert_equal 3,m.report_list_of_measures(:filter_below_accuracy=>1).length
|
156
|
+
assert_equal 3,m.report_list_of_measures(:filter_below_accuracy=>500).length
|
157
|
+
assert_equal 3,m.report_list_of_measures(:filter_below_percent=>10).length
|
158
|
+
assert_equal 2,m.report_list_of_measures(:filter_below_percent=>45).length
|
137
159
|
end
|
138
160
|
|
139
161
|
def test_methods_with_measure
|