Class: TestMinitestBenchmark
- Inherits:
-
Minitest::Test
show all
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb
Overview
Constant Summary
Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS
Minitest::Assertions::E, Minitest::Assertions::UNDEFINED
Minitest::Runnable::SIGNALS
Instance Attribute Summary
#assertions, #failures, #time
Instance Method Summary
collapse
#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler
#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?
#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown
#class_name, #error?, #location, #passed?, #result_code, #skipped?
#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #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, #fail_after, #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_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff
#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler
Instance Method Details
#assert_fit(msg, x, y, fit, exp_a, exp_b) ⇒ Object
121
122
123
124
125
126
127
128
129
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 121
def assert_fit msg, x, y, fit, exp_a, exp_b
bench = Minitest::Benchmark.new :blah
a, b, rr = bench.send "fit_#{msg}", x, y
assert_operator rr, :>=, fit if fit
assert_in_delta exp_a, a
assert_in_delta exp_b, b
end
|
#test_cls_bench_exp ⇒ Object
9
10
11
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 9
def test_cls_bench_exp
assert_equal [2, 4, 8, 16, 32], Minitest::Benchmark.bench_exp(2, 32, 2)
end
|
#test_cls_bench_linear ⇒ Object
13
14
15
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 13
def test_cls_bench_linear
assert_equal [2, 4, 6, 8, 10], Minitest::Benchmark.bench_linear(2, 10, 2)
end
|
#test_cls_bench_range ⇒ Object
28
29
30
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 28
def test_cls_bench_range
assert_equal [1, 10, 100, 1_000, 10_000], Minitest::Benchmark.bench_range
end
|
#test_cls_runnable_methods ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 17
def test_cls_runnable_methods
assert_equal [], Minitest::Benchmark.runnable_methods
c = Class.new(Minitest::Benchmark) do
def bench_blah
end
end
assert_equal ["bench_blah"], c.runnable_methods
end
|
#test_fit_constant_clean ⇒ Object
63
64
65
66
67
68
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 63
def test_fit_constant_clean
x = (1..5).to_a
y = [5.0, 5.0, 5.0, 5.0, 5.0]
assert_fit :linear, x, y, nil, 5.0, 0
end
|
#test_fit_constant_noisy ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 70
def test_fit_constant_noisy
x = (1..5).to_a
y = [1.0, 1.2, 1.0, 0.8, 1.0]
assert_fit :linear, x, y, nil, 1.12, -0.04
end
|
#test_fit_exponential_clean ⇒ Object
32
33
34
35
36
37
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 32
def test_fit_exponential_clean
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = x.map { |n| 1.1 * Math.exp(2.1 * n) }
assert_fit :exponential, x, y, 1.0, 1.1, 2.1
end
|
#test_fit_exponential_noisy ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 39
def test_fit_exponential_noisy
x = [1.0, 1.9, 2.6, 3.4, 5.0]
y = [12, 10, 8.2, 6.9, 5.9]
assert_fit :exponential, x, y, 0.95, 13.81148, -0.1820
end
|
#test_fit_linear_clean ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 78
def test_fit_linear_clean
x = (1..5).to_a
y = x.map { |n| 2.2 * n + 3.1 }
assert_fit :linear, x, y, 1.0, 3.1, 2.2
end
|
#test_fit_linear_noisy ⇒ Object
86
87
88
89
90
91
92
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 86
def test_fit_linear_noisy
x = [ 60, 61, 62, 63, 65]
y = [3.1, 3.6, 3.8, 4.0, 4.1]
assert_fit :linear, x, y, 0.8315, -7.9635, 0.1878
end
|
#test_fit_logarithmic_clean ⇒ Object
47
48
49
50
51
52
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 47
def test_fit_logarithmic_clean
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = x.map { |n| 1.1 + 2.1 * Math.log(n) }
assert_fit :logarithmic, x, y, 1.0, 1.1, 2.1
end
|
#test_fit_logarithmic_noisy ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 54
def test_fit_logarithmic_noisy
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [0.0, 0.6935, 1.0995, 1.3873, 1.6097]
assert_fit :logarithmic, x, y, 0.95, 0, 1
end
|
#test_fit_power_clean ⇒ Object
94
95
96
97
98
99
100
101
102
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 94
def test_fit_power_clean
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.0, 4.0, 9.0, 16.0, 25.0]
assert_fit :power, x, y, 1.0, 1.0, 2.0
end
|
#test_fit_power_noisy ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_benchmark.rb', line 104
def test_fit_power_noisy
x = [10, 12, 15, 17, 20, 22, 25, 27, 30, 32, 35]
y = [95, 105, 125, 141, 173, 200, 253, 298, 385, 459, 602]
assert_fit :power, x, y, 0.90, 2.6217, 1.4556
x = [15_000, 25_000, 35_000, 50_000, 75_000, 100_000]
y = [0.154, 0.283, 0.402, 0.55, 0.733, 0.843]
assert_fit :power, x, y, 0.96, 3.119e-5, 0.8959
end
|