Skip to content

Instantly share code, notes, and snippets.

@rodrigoflores
Created July 23, 2012 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigoflores/3163429 to your computer and use it in GitHub Desktop.
Save rodrigoflores/3163429 to your computer and use it in GitHub Desktop.
Assert Linear
require 'minitest/autorun'
require 'minitest/benchmark'
load 'lib/klass.rb'
class TestKlass < MiniTest::Unit::TestCase
describe "linear" do
it "is linear" do
assert_performance_linear 0.9999 do |n| # n is a range value
Klass.linear(n)
end
end
end
describe "quadratic" do
it "is quadratic" do
assert_performance_constant 0.99 do |n| # n is a range value
10.times do
Klass.linear(n)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment