File: test_benchmark_suite.rb

package info (click to toggle)
ruby-benchmark-suite 1.0.0%2Bgit.20130122.5bded6-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd
  • size: 128 kB
  • ctags: 19
  • sloc: ruby: 291; makefile: 12
file content (20 lines) | stat: -rw-r--r-- 403 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require "test/unit"
require "benchmark_suite"

class TestBenchmarkSuite < Test::Unit::TestCase
  def test_ips
    s = Benchmark::Suite.create do |s|
      s.quiet!

      Benchmark.ips(1,1) do |x|
        x.report("sleep") { sleep(0.25) }
      end
    end

    rep = s.report.first

    assert_equal "sleep", rep.label
    assert_equal 4, rep.iterations
    assert_in_delta 4.0, rep.ips, 0.2
  end
end