rumx 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. data/History.md +5 -0
  2. data/lib/rumx/beans/timer.rb +18 -16
  3. metadata +2 -2
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Rumx Changelog
2
2
  =====================
3
3
 
4
+ 0.1.1
5
+
6
+ - Changed Bean::Timer attribute total_count to count and added non-resettable total_count as attribute.
7
+ For munin, this allows the total count to be collected in a separate call without worrying about it being reset.
8
+
4
9
  0.1.0
5
10
 
6
11
  - Removed the following methods and the equivalient writers and accessors to hopefully make the commands more consistent:
@@ -3,27 +3,28 @@ module Rumx
3
3
  class Timer
4
4
  include Bean
5
5
 
6
- bean_attr_reader :total_count, :integer, 'Number of times the measured block has run'
7
- bean_attr_reader :total_time, :float, 'Total time (msec) for all the runs of the timed instruction'
8
- bean_attr_reader :max_time, :float, 'The maximum time (msec) for all the runs of the timed instruction'
9
- bean_attr_reader :min_time, :float, 'The minimum time (msec) for all the runs of the timed instruction'
10
- bean_attr_reader :last_time, :float, 'The time (msec) for the last run of the timed instruction'
11
- bean_reader :avg_time, :float, 'The average time (msec) for all runs of the timed instruction'
12
- bean_writer :reset, :boolean, 'Reset the times and counts to zero (Note that last_time is not reset)'
6
+ bean_attr_reader :total_count, :integer, 'Number of times the measured block has run'
7
+ bean_attr_reader :count, :integer, 'Number of times the measured block has run since the last reset'
8
+ bean_attr_reader :max_time, :float, 'The maximum time (msec) for all the runs of the timed instruction'
9
+ bean_attr_reader :min_time, :float, 'The minimum time (msec) for all the runs of the timed instruction'
10
+ bean_attr_reader :last_time, :float, 'The time (msec) for the last run of the timed instruction'
11
+ bean_reader :avg_time, :float, 'The average time (msec) for all runs of the timed instruction'
12
+ bean_writer :reset, :boolean, 'Reset the times and counts to zero (Note that total_count and last_time are not reset)'
13
13
 
14
14
  def initialize(opts={})
15
15
  # Force initialization of Bean#bean_monitor to avoid race condition (See bean.rb)
16
16
  bean_monitor
17
- @last_time = 0.0
18
- self.reset = true
17
+ @total_count = 0
18
+ @last_time = 0.0
19
+ self.reset = true
19
20
  end
20
21
 
21
22
  def reset=(val)
22
23
  if val
23
- @total_count = 0
24
- @min_time = nil
25
- @max_time = 0.0
26
- @total_time = 0.0
24
+ @count = 0
25
+ @min_time = nil
26
+ @max_time = 0.0
27
+ @sum_time = 0.0
27
28
  end
28
29
  end
29
30
 
@@ -35,8 +36,9 @@ module Rumx
35
36
  current_time = (Time.now.to_f - start_time.to_f) * 1000.0
36
37
  bean_synchronize do
37
38
  @last_time = current_time
39
+ @count += 1
38
40
  @total_count += 1
39
- @total_time += current_time
41
+ @sum_time += current_time
40
42
  @min_time = current_time if !@min_time || current_time < @min_time
41
43
  @max_time = current_time if current_time > @max_time
42
44
  end
@@ -50,13 +52,13 @@ module Rumx
50
52
 
51
53
  def avg_time
52
54
  # Do the best we can w/o mutexing
53
- count, time = @total_count, @total_time
55
+ count, time = @count, @sum_time
54
56
  return 0.0 if count == 0
55
57
  time / count
56
58
  end
57
59
 
58
60
  def to_s
59
- "total_count=#{@total_count} min=#{('%.1f' % min_time)}ms max=#{('%.1f' % max_time)}ms avg=#{('%.1f' % avg_time)}ms"
61
+ "total_count=#{@total_count} count=#{@count} min=#{('%.1f' % min_time)}ms max=#{('%.1f' % max_time)}ms avg=#{('%.1f' % avg_time)}ms"
60
62
  end
61
63
  end
62
64
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rumx
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brad Pardee
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-21 00:00:00 Z
13
+ date: 2011-12-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra