Sha256: 4ae4299d5be8e93c3306360df9fd1fd1b29ef8f088b762cd66c3d8a7ce3bc066

Contents?: true

Size: 478 Bytes

Versions: 3

Compression:

Stored size: 478 Bytes

Contents

require "test/unit"
require "benchmark/ips"
require "stringio"

class TestBenchmarkIPS < Test::Unit::TestCase
  def setup
    @old_stdout = $stdout
    $stdout = StringIO.new
  end

  def teardown
    $stdout = @old_stdout
  end

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

    rep = reports.first

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
benchmark-ips-1.2.0 test/test_benchmark_ips.rb
benchmark-ips-1.1.0 test/test_benchmark_ips.rb
benchmark-ips-1.0.0 test/test_benchmark_ips.rb