Class: Minitest::BenchSpec
- Extended by:
- Spec::DSL
- Defined in:
- lib/minitest/benchmark.rb
Constant Summary
Constants included from Spec::DSL
Constants inherited from Test
Constants included from Assertions
Instance Attribute Summary
Attributes included from Spec::DSL
Attributes inherited from Test
Attributes inherited from Runnable
Class Method Summary collapse
-
.bench(name, &block) ⇒ Object
This is used to define a new benchmark method.
-
.bench_performance_constant(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is constant.
-
.bench_performance_exponential(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is exponential.
-
.bench_performance_linear(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is linear.
-
.bench_range(&block) ⇒ Object
Specifies the ranges used for benchmarking for that class.
Methods included from Spec::DSL
after, before, children, create, describe_stack, it, let, name, nuke_test_methods!, register_spec_type, spec_type, subject, to_s
Methods inherited from Benchmark
#assert_performance, #assert_performance_constant, #assert_performance_exponential, #assert_performance_linear, #assert_performance_logarithmic, #assert_performance_power, bench_exp, bench_linear, #fit_error, #fit_exponential, #fit_linear, #fit_logarithmic, #fit_power, #io, io, run, runnable_methods, #sigma, #validation_for_fit
Methods inherited from Test
#capture_exceptions, #capture_io, #capture_subprocess_io, #error?, i_suck_and_my_tests_are_order_dependent!, #location, make_my_diffs_pretty!, #marshal_dump, #marshal_load, old_test_order, parallelize_me!, #passed?, #result_code, #run, runnable_methods, #simple_capture_io, #simple_capture_subprocess_io, #skipped?, synchronize, test_order, #time_it, #to_s, #with_info_handler
Methods included from Guard
#jruby?, #maglev?, #mri?, #rubinius?, #windows?
Methods included from Test::LifecycleHooks
#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown
Methods included from Assertions
#assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_output, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skipped?
Methods inherited from Runnable
#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, runnable_methods, runnables, #skipped?, with_info_handler
Constructor Details
This class inherits a constructor from Minitest::Runnable
Class Method Details
.bench(name, &block) ⇒ Object
This is used to define a new benchmark method. You usually don’t use this directly and is intended for those needing to write new performance curve fits (eg: you need a specific polynomial fit).
See ::bench_performance_linear for an example of how to use this.
356 357 358 |
# File 'lib/minitest/benchmark.rb', line 356 def self.bench name, &block define_method "bench_#{name.gsub(/\W+/, '_')}", &block end |
.bench_performance_constant(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is constant.
describe "my class" do
bench_performance_constant "zoom_algorithm!" do |n|
@obj.zoom_algorithm!(n)
end
end
400 401 402 403 404 |
# File 'lib/minitest/benchmark.rb', line 400 def self.bench_performance_constant name, threshold = 0.99, &work bench name do assert_performance_constant threshold, &work end end |
.bench_performance_exponential(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is exponential.
describe "my class" do
bench_performance_exponential "algorithm" do |n|
@obj.algorithm(n)
end
end
415 416 417 418 419 |
# File 'lib/minitest/benchmark.rb', line 415 def self.bench_performance_exponential name, threshold = 0.99, &work bench name do assert_performance_exponential threshold, &work end end |
.bench_performance_linear(name, threshold = 0.99, &work) ⇒ Object
Create a benchmark that verifies that the performance is linear.
describe "my class" do
bench_performance_linear "fast_algorithm", 0.9999 do |n|
@obj.fast_algorithm(n)
end
end
385 386 387 388 389 |
# File 'lib/minitest/benchmark.rb', line 385 def self.bench_performance_linear name, threshold = 0.99, &work bench name do assert_performance_linear threshold, &work end end |
.bench_range(&block) ⇒ Object
Specifies the ranges used for benchmarking for that class.
bench_range do
bench_exp(2, 16, 2)
end
See Minitest::Benchmark#bench_range for more details.
369 370 371 372 373 374 |
# File 'lib/minitest/benchmark.rb', line 369 def self.bench_range &block return super unless block = (class << self; self; end) .send :define_method, "bench_range", &block end |