Sha256: 9ee9e45585c9cf03d31634fe27fbbee9f55be9f384e8747879095bf2e72a0c24

Contents?: true

Size: 693 Bytes

Versions: 9

Compression:

Stored size: 693 Bytes

Contents

#!/usr/bin/env ruby

require 'rspec'
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'panoptimon-plugin-daemon_health/rollup'

describe('calculate a moving average') {
  it('works') {
    start = Time.now
    roller = Rollup.new(start, {})
    roller.log(x: 60*7)
    out = roller.roll(start+60)
    out['300'][:x][:nps].should == 7
    out['60'][:x][:nps].should == 7
    roller.log(x: 60*7)
    out = roller.roll(start+60*2)
    out['300'][:x][:nps].should == 7
    out['60'][:x][:nps].should == 7
    roller.log(x: 60*1)
    out = roller.roll(start+60*3)
    out['300'][:x][:nps].should == ((60*7+60*7+60).to_f/(60*3)).round(4)
    out['60'][:x][:nps].should == 1
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
panoptimon-0.4.5 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.4.4 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.4.2 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.4.1 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.4.0 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.3.0 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.2.0 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.1.0 plugins/daemon_health/spec/moving_avg_spec.rb
panoptimon-0.0.2 plugins/daemon_health/spec/moving_avg_spec.rb