metriks 0.8.3 → 0.8.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Metriks
3
- VERSION = '0.8.3'
3
+ VERSION = '0.8.4'
4
4
 
5
5
  def self.get(name)
6
6
  Metriks::Registry.default.get(name)
@@ -38,7 +38,7 @@ module Metriks
38
38
 
39
39
  def update(value, timestamp = Time.now)
40
40
  @mutex.synchronize do
41
- priority = Math.exp(timestamp - @start_time) / rand
41
+ priority = weight(timestamp - @start_time) / rand
42
42
  new_count = @count.update { |v| v + 1 }
43
43
  if new_count <= @reservoir_size
44
44
  @values[priority] = value
@@ -63,6 +63,10 @@ module Metriks
63
63
  end
64
64
  end
65
65
 
66
+ def weight(time)
67
+ Math.exp(@alpha * time)
68
+ end
69
+
66
70
  def rescale(now, next_time)
67
71
  if @next_scale_time.compare_and_swap(next_time, now + RESCALE_THRESHOLD)
68
72
  @mutex.synchronize do
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.3'
16
+ s.version = '0.8.4'
17
17
  s.date = '2012-02-27'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 3
9
- version: 0.8.3
8
+ - 4
9
+ version: 0.8.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Eric Lindvall