metriks 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/metriks.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Metriks
3
- VERSION = '0.8.2'
3
+ VERSION = '0.8.3'
4
4
 
5
5
  def self.get(name)
6
6
  Metriks::Registry.default.get(name)
@@ -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) + (upper - lower)
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.2'
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
@@ -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
- 50.times do |idx|
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 25.5, snapshot.median
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
- 50.times do |idx|
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 25.5, snapshot.median
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
- @timer.time do
16
- sleep 0.1
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 2
9
- version: 0.8.2
8
+ - 3
9
+ version: 0.8.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Eric Lindvall