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 CHANGED
@@ -1 +1 @@
1
- 1.3.4
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>0 && m.time.real>0
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
@@ -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, :max_title => max_title,
89
+ rep << format_measure(:title => title, :max_title => max_title,
83
90
  :percent => percents[what]||0.0,
84
- :count => m.count, :max_count => max_count,
91
+ :count => m.count, :max_count => max_count,
85
92
  :time => m.time,
86
- :accuracy => format_accuracy(perf.accuracy(m.path)), :max_accuracy => MAX_ACCURACY_SIZE,
93
+ :accuracy => format_accuracy(accuracy), :max_accuracy => MAX_ACCURACY_SIZE,
87
94
  :options => options)
88
95
  end
89
96
 
data/rubyperf.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyperf}
8
- s.version = "1.3.4"
8
+ s.version = "1.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["lpasqualis"]
@@ -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
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 4
8
+ - 5
9
9
  segments_generated: true
10
- version: 1.3.4
10
+ version: 1.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - lpasqualis