metriks 0.8.2 → 0.8.3
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.
- data/lib/metriks.rb +1 -1
- data/lib/metriks/snapshot.rb +3 -1
- data/metriks.gemspec +1 -1
- data/test/histogram_test.rb +4 -4
- data/test/timer_test.rb +5 -2
- metadata +2 -2
data/lib/metriks.rb
CHANGED
data/lib/metriks/snapshot.rb
CHANGED
@@ -7,6 +7,8 @@ class Snapshot
|
|
7
7
|
P99_Q = 0.99
|
8
8
|
P999_Q = 0.999
|
9
9
|
|
10
|
+
attr_reader :values
|
11
|
+
|
10
12
|
def initialize(values)
|
11
13
|
@values = values.sort
|
12
14
|
end
|
@@ -23,7 +25,7 @@ class Snapshot
|
|
23
25
|
|
24
26
|
lower = @values[pos.to_i - 1]
|
25
27
|
upper = @values[pos.to_i]
|
26
|
-
lower + (pos - pos.floor)
|
28
|
+
lower + (pos - pos.floor) * (upper - lower)
|
27
29
|
end
|
28
30
|
|
29
31
|
def size
|
data/metriks.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'metriks'
|
16
|
-
s.version = '0.8.
|
16
|
+
s.version = '0.8.3'
|
17
17
|
s.date = '2012-02-27'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
data/test/histogram_test.rb
CHANGED
@@ -46,13 +46,13 @@ class HistogramTest < Test::Unit::TestCase
|
|
46
46
|
def test_uniform_sample_snashot
|
47
47
|
@histogram = Metriks::Histogram.new(Metriks::UniformSample.new(Metriks::Histogram::DEFAULT_SAMPLE_SIZE))
|
48
48
|
|
49
|
-
|
49
|
+
100.times do |idx|
|
50
50
|
@histogram.update(idx)
|
51
51
|
end
|
52
52
|
|
53
53
|
snapshot = @histogram.snapshot
|
54
54
|
|
55
|
-
assert_equal
|
55
|
+
assert_equal 49.5, snapshot.median
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_exponential_sample_min
|
@@ -95,13 +95,13 @@ class HistogramTest < Test::Unit::TestCase
|
|
95
95
|
def test_exponential_sample_snashot
|
96
96
|
@histogram = Metriks::Histogram.new(Metriks::ExponentiallyDecayingSample.new(Metriks::Histogram::DEFAULT_SAMPLE_SIZE, Metriks::Histogram::DEFAULT_ALPHA))
|
97
97
|
|
98
|
-
|
98
|
+
100.times do |idx|
|
99
99
|
@histogram.update(idx)
|
100
100
|
end
|
101
101
|
|
102
102
|
snapshot = @histogram.snapshot
|
103
103
|
|
104
|
-
assert_equal
|
104
|
+
assert_equal 49.5, snapshot.median
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
data/test/timer_test.rb
CHANGED
@@ -12,11 +12,14 @@ class TimerTest < Test::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_timer
|
15
|
-
|
16
|
-
|
15
|
+
3.times do
|
16
|
+
@timer.time do
|
17
|
+
sleep 0.1
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
assert_in_delta 0.1, @timer.mean, 0.01
|
22
|
+
assert_in_delta 0.1, @timer.snapshot.median, 0.01
|
20
23
|
end
|
21
24
|
|
22
25
|
def test_timer_without_block
|