mtrc 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +10 -0
- data/lib/mtrc.rb +1 -0
- data/lib/mtrc/rate.rb +19 -0
- data/lib/mtrc/version.rb +1 -1
- metadata +5 -6
data/README.markdown
CHANGED
@@ -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...
|
data/lib/mtrc.rb
CHANGED
data/lib/mtrc/rate.rb
ADDED
@@ -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
|
data/lib/mtrc/version.rb
CHANGED
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.
|
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-
|
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.
|
48
|
+
rubygems_version: 1.8.10
|
50
49
|
signing_key:
|
51
50
|
specification_version: 3
|
52
51
|
summary: Minimal metric aggregation.
|