benchmark-ips 2.3.0 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +228 -0
- data/LICENSE +20 -0
- data/README.md +129 -29
- data/examples/advanced.rb +20 -0
- data/examples/hold.rb +41 -0
- data/examples/save.rb +50 -0
- data/examples/simple.rb +47 -0
- data/lib/benchmark/compare.rb +59 -23
- data/lib/benchmark/ips/job/entry.rb +95 -0
- data/lib/benchmark/ips/job/noop_report.rb +27 -0
- data/lib/benchmark/ips/job/stdout_report.rb +64 -0
- data/lib/benchmark/ips/job.rb +211 -150
- data/lib/benchmark/ips/noop_suite.rb +25 -0
- data/lib/benchmark/ips/report.rb +53 -30
- data/lib/benchmark/ips/share.rb +50 -0
- data/lib/benchmark/ips/stats/bootstrap.rb +58 -0
- data/lib/benchmark/ips/stats/sd.rb +45 -0
- data/lib/benchmark/ips/stats/stats_metric.rb +21 -0
- data/lib/benchmark/ips.rb +91 -24
- data/lib/benchmark/timing.rb +39 -16
- metadata +24 -31
- data/.autotest +0 -23
- data/.gemtest +0 -0
- data/History.txt +0 -87
- data/Manifest.txt +0 -11
- data/Rakefile +0 -26
- data/test/test_benchmark_ips.rb +0 -161
data/test/test_benchmark_ips.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "benchmark/ips"
|
3
|
-
require "stringio"
|
4
|
-
|
5
|
-
class TestBenchmarkIPS < Minitest::Test
|
6
|
-
def setup
|
7
|
-
@old_stdout = $stdout
|
8
|
-
$stdout = StringIO.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
$stdout = @old_stdout
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_kwargs
|
16
|
-
Benchmark.ips(:time => 1, :warmup => 1, :quiet => false) do |x|
|
17
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
18
|
-
end
|
19
|
-
|
20
|
-
assert $stdout.string.size > 0
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_output
|
24
|
-
Benchmark.ips(1) do |x|
|
25
|
-
x.report("operation") { 100 * 100 }
|
26
|
-
end
|
27
|
-
|
28
|
-
assert $stdout.string.size > 0
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_quiet
|
32
|
-
Benchmark.ips(1, nil, true) do |x|
|
33
|
-
x.report("operation") { 100 * 100 }
|
34
|
-
end
|
35
|
-
|
36
|
-
assert $stdout.string.size.zero?
|
37
|
-
|
38
|
-
Benchmark.ips(:quiet => true) do |x|
|
39
|
-
x.report("operation") { 100 * 100 }
|
40
|
-
end
|
41
|
-
|
42
|
-
assert $stdout.string.size.zero?
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_ips
|
46
|
-
report = Benchmark.ips do |x|
|
47
|
-
x.config(:time => 1, :warmup => 1)
|
48
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
49
|
-
x.report("sleep 0.05") { sleep(0.05) }
|
50
|
-
x.compare!
|
51
|
-
end
|
52
|
-
|
53
|
-
rep1 = report.entries[0]
|
54
|
-
rep2 = report.entries[1]
|
55
|
-
|
56
|
-
assert_equal "sleep 0.25", rep1.label
|
57
|
-
assert_equal 4, rep1.iterations
|
58
|
-
assert_in_delta 4.0, rep1.ips, 0.2
|
59
|
-
|
60
|
-
assert_equal "sleep 0.05", rep2.label
|
61
|
-
assert_in_delta 20.0, rep2.iterations.to_f, 1.0
|
62
|
-
assert_in_delta 20.0, rep2.ips, 1.0
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_ips_alternate_config
|
66
|
-
report = Benchmark.ips do |x|
|
67
|
-
x.time = 1
|
68
|
-
x.warmup = 1
|
69
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
70
|
-
end
|
71
|
-
|
72
|
-
rep = report.entries.first
|
73
|
-
|
74
|
-
assert_equal "sleep 0.25", rep.label
|
75
|
-
assert_equal 4, rep.iterations
|
76
|
-
assert_in_delta 4.0, rep.ips, 0.2
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_ips_old_config
|
80
|
-
report = Benchmark.ips(1,1) do |x|
|
81
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
82
|
-
end
|
83
|
-
|
84
|
-
rep = report.entries.first
|
85
|
-
|
86
|
-
assert_equal "sleep 0.25", rep.label
|
87
|
-
assert_equal 4, rep.iterations
|
88
|
-
assert_in_delta 4.0, rep.ips, 0.2
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_ips_config_suite
|
92
|
-
suite = Struct.new(:calls) do
|
93
|
-
def method_missing(method, *args)
|
94
|
-
calls << method
|
95
|
-
end
|
96
|
-
end.new([])
|
97
|
-
|
98
|
-
Benchmark.ips(0.1, 0.1) do |x|
|
99
|
-
x.config(:suite => suite)
|
100
|
-
x.report("job") {}
|
101
|
-
end
|
102
|
-
|
103
|
-
assert_equal [:warming, :warmup_stats, :running, :add_report], suite.calls
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_ips_defaults
|
107
|
-
report = Benchmark.ips do |x|
|
108
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
109
|
-
end
|
110
|
-
|
111
|
-
rep = report.entries.first
|
112
|
-
|
113
|
-
assert_equal "sleep 0.25", rep.label
|
114
|
-
assert_equal 4*5, rep.iterations
|
115
|
-
assert_in_delta 4.0, rep.ips, 0.2
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_ips_report_using_symbol
|
119
|
-
report = Benchmark.ips do |x|
|
120
|
-
x.report(:sleep_a_quarter_second) { sleep(0.25) }
|
121
|
-
end
|
122
|
-
|
123
|
-
rep = report.entries.first
|
124
|
-
|
125
|
-
assert_equal :sleep_a_quarter_second, rep.label
|
126
|
-
assert_equal 4*5, rep.iterations
|
127
|
-
assert_in_delta 4.0, rep.ips, 0.2
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_ips_default_data
|
131
|
-
report = Benchmark.ips do |x|
|
132
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
133
|
-
end
|
134
|
-
|
135
|
-
all_data = report.data
|
136
|
-
|
137
|
-
assert all_data
|
138
|
-
assert_equal "sleep 0.25", all_data[0][:name]
|
139
|
-
assert all_data[0][:ips]
|
140
|
-
assert all_data[0][:stddev]
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_json_output
|
144
|
-
json_file = Tempfile.new("data.json")
|
145
|
-
|
146
|
-
Benchmark.ips do |x|
|
147
|
-
x.report("sleep 0.25") { sleep(0.25) }
|
148
|
-
x.json! json_file.path
|
149
|
-
end
|
150
|
-
|
151
|
-
json_data = json_file.read
|
152
|
-
assert json_data
|
153
|
-
|
154
|
-
data = JSON.parse json_data
|
155
|
-
assert data
|
156
|
-
assert_equal 1, data.size
|
157
|
-
assert_equal "sleep 0.25", data[0]["name"]
|
158
|
-
assert data[0]["ips"]
|
159
|
-
assert data[0]["stddev"]
|
160
|
-
end
|
161
|
-
end
|