File: timer_test.rb

package info (click to toggle)
ruby-metriks 0.9.9.8-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,877; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 499 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'test_helper'

require 'metriks/timer'

class TimerTest < Test::Unit::TestCase
  def setup
    @timer = Metriks::Timer.new
  end

  def teardown
    @timer.stop
  end

  def test_timer
    3.times do
      @timer.time do
        sleep 0.1
      end
    end

    assert_in_delta 0.1, @timer.mean, 0.01
    assert_in_delta 0.1, @timer.snapshot.median, 0.01
  end

  def test_timer_without_block
    t = @timer.time
    sleep 0.1
    t.stop

    assert_in_delta 0.1, @timer.mean, 0.01
  end
end