benchmark_unit
Machine-independent benchmark assertions for your unit tests.
License
Copyright 2007 Cloudburst, LLC. See included LICENSE file.
The public certificate for this gem is at rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem.
Features
-
Test::Unit-compatible
-
machine-independent measurement units
Installation
sudo gem install benchmark_unit
Usage
First, require the library. Then, in a regular Test::Unit::TestCase, call either assert_faster
or assert_slower
. Pass a number of RubySeconds and a block to benchmark.
require 'benchmark/unit'
class MyTest < Test::Unit::TestCase
def test_speed_of_critical_method
assert_faster(3) do
MyCriticalMethod("data")
end
end
end
You do not have to manually run the block multiple times; the library does that for you.
To find how many RubySeconds to start with, just omit the argument to the assert_faster
or assert_slower
call. The test will fail and report how long your block took. Add a little bit and use that as your initial failure point.
See Benchmark::RubySeconds for more details.
Reporting problems
Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.