mtrc 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,3 +43,13 @@ Which requests take the longest?
43
43
  (@m % 95).value # => "?bacon=strips&bacon=strips&bacon=strips"
44
44
 
45
45
  It's MIT licensed, bro. Pull requests? Roll one up homie.
46
+
47
+ Rates
48
+ ---
49
+
50
+ r = Mtrc::Rate.new
51
+ 10.times do
52
+ r.tick 2
53
+ end
54
+ sleep 1
55
+ r.rate #=> 19.999...
@@ -8,4 +8,5 @@ module Mtrc
8
8
  require 'mtrc/sample'
9
9
  require 'mtrc/samples'
10
10
  require 'mtrc/sorted_samples'
11
+ require 'mtrc/rate'
11
12
  end
@@ -0,0 +1,19 @@
1
+ class Mtrc::Rate
2
+ # A time differential. Accumulates ticks, and provides the rate in
3
+ # ticks/second since t0.
4
+ attr_accessor :t0
5
+ attr_accessor :ticks
6
+ def initialize
7
+ @t0 = Time.now
8
+ @ticks = 0
9
+ end
10
+
11
+ def rate
12
+ @ticks / (Time.now - @t0)
13
+ end
14
+
15
+ def tick(delta = 1)
16
+ @ticks += delta
17
+ end
18
+ alias << tick
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Mtrc
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtrc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-01 00:00:00.000000000 -07:00
13
- default_executable:
12
+ date: 2011-09-13 00:00:00.000000000Z
14
13
  dependencies: []
15
14
  description:
16
15
  email: aphyr@aphyr.com
@@ -19,13 +18,13 @@ extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
20
  - lib/mtrc.rb
21
+ - lib/mtrc/rate.rb
22
22
  - lib/mtrc/sample.rb
23
23
  - lib/mtrc/version.rb
24
- - lib/mtrc/sorted_samples.rb
25
24
  - lib/mtrc/samples.rb
25
+ - lib/mtrc/sorted_samples.rb
26
26
  - LICENSE
27
27
  - README.markdown
28
- has_rdoc: true
29
28
  homepage: https://github.com/aphyr/mtrc
30
29
  licenses: []
31
30
  post_install_message:
@@ -46,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
45
  version: '0'
47
46
  requirements: []
48
47
  rubyforge_project: mtrc
49
- rubygems_version: 1.6.2
48
+ rubygems_version: 1.8.10
50
49
  signing_key:
51
50
  specification_version: 3
52
51
  summary: Minimal metric aggregation.