benchmark-ips 2.8.3 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +23 -2
- data/Manifest.txt +2 -0
- data/README.md +8 -4
- data/lib/benchmark/ips/job/noop_report.rb +27 -0
- data/lib/benchmark/ips/job.rb +37 -17
- data/lib/benchmark/ips/noop_suite.rb +25 -0
- data/lib/benchmark/ips/share.rb +3 -1
- data/lib/benchmark/ips.rb +6 -13
- data/test/test_benchmark_ips.rb +69 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22ac46ad04849b7302dc6cc8c1fe2521c73d16fa9f47e1b0af7abf175d11d1f
|
4
|
+
data.tar.gz: 2ea1a4d8b23e6efd542c204b8e557734ea4cf6c5aebc51db8aca2ac036cd2bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bdfb5486834ee180b70371299387eb0fc6e6137de5d17e9e547618ba12cb72cb845893915c0195f6153ef44b4adb8ba6138504d31de4a2f523d638375cb2794
|
7
|
+
data.tar.gz: c597571580a1379603e0789b98f0d9eb0fde836d409f257474c24b39d1557a681b78c7a2d239dcc725acbbc07ed3dcca59681b23574b8c29770f63a7f36835c5
|
data/History.txt
CHANGED
@@ -1,11 +1,32 @@
|
|
1
|
+
=== 2.9.2 / 2021-10-10
|
2
|
+
|
3
|
+
* Bug fix
|
4
|
+
* Fix a problem with certain configs of quiet mode
|
5
|
+
|
6
|
+
=== 2.9.1 / 2021-05-24
|
7
|
+
|
8
|
+
* Bug fix
|
9
|
+
* Include all files in gem
|
10
|
+
|
11
|
+
=== 2.9.0 / 2021-05-21
|
12
|
+
|
13
|
+
* Features
|
14
|
+
* Suite can now be set via an accessor
|
15
|
+
* Default SHARE_URL is now `ips.fastruby.io`, operated by Ombu Labs.
|
16
|
+
|
17
|
+
=== 2.8.4 / 2020-12-03
|
18
|
+
|
19
|
+
* Bug fix
|
20
|
+
* Fixed hold! when results file does not exist.
|
21
|
+
|
1
22
|
=== 2.8.3 / 2020-08-28
|
2
23
|
|
3
|
-
* Bug fix
|
24
|
+
* Bug fix
|
4
25
|
* Fixed inaccuracy caused by integer overflows.
|
5
26
|
|
6
27
|
=== 2.8.2 / 2020-05-04
|
7
28
|
|
8
|
-
* Bug fix
|
29
|
+
* Bug fix
|
9
30
|
* Fixed problems with Manifest.txt.
|
10
31
|
* Empty interim results files are ignored.
|
11
32
|
|
data/Manifest.txt
CHANGED
@@ -7,7 +7,9 @@ lib/benchmark/compare.rb
|
|
7
7
|
lib/benchmark/ips.rb
|
8
8
|
lib/benchmark/ips/job.rb
|
9
9
|
lib/benchmark/ips/job/entry.rb
|
10
|
+
lib/benchmark/ips/job/noop_report.rb
|
10
11
|
lib/benchmark/ips/job/stdout_report.rb
|
12
|
+
lib/benchmark/ips/noop_suite.rb
|
11
13
|
lib/benchmark/ips/report.rb
|
12
14
|
lib/benchmark/ips/share.rb
|
13
15
|
lib/benchmark/ips/stats/bootstrap.rb
|
data/README.md
CHANGED
@@ -186,11 +186,15 @@ end
|
|
186
186
|
|
187
187
|
### Online sharing
|
188
188
|
|
189
|
-
If you want to share
|
190
|
-
with `SHARE=1` argument.
|
191
|
-
|
189
|
+
If you want to quickly share your benchmark result with others, run you benchmark
|
190
|
+
with `SHARE=1` argument. For example: `SHARE=1 ruby my_benchmark.rb`.
|
191
|
+
|
192
|
+
Result will be sent to [benchmark.fyi](https://ips.fastruby.io/) and benchmark-ips
|
192
193
|
will display the link to share the benchmark's result.
|
193
194
|
|
195
|
+
If you want to run your own instance of [benchmark.fyi](https://github.com/evanphx/benchmark.fyi)
|
196
|
+
and share it to that instance, you can do this: `SHARE_URL=https://ips.example.com ruby my_benchmark.rb`
|
197
|
+
|
194
198
|
### Advanced Statistics
|
195
199
|
|
196
200
|
By default, the margin of error shown is plus-minus one standard deviation. If
|
@@ -227,7 +231,7 @@ Benchmark.ips do |x|
|
|
227
231
|
|
228
232
|
x.stats = :bootstrap
|
229
233
|
x.confidence = 95
|
230
|
-
|
234
|
+
|
231
235
|
# confidence is 95% by default, so it can be omitted
|
232
236
|
|
233
237
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Benchmark
|
2
|
+
module IPS
|
3
|
+
class Job
|
4
|
+
class NoopReport
|
5
|
+
def start_warming
|
6
|
+
end
|
7
|
+
|
8
|
+
def start_running
|
9
|
+
end
|
10
|
+
|
11
|
+
def footer
|
12
|
+
end
|
13
|
+
|
14
|
+
def warming(a, b)
|
15
|
+
end
|
16
|
+
|
17
|
+
def warmup_stats(a, b)
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_report(a, b)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_method :running, :warming
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/benchmark/ips/job.rb
CHANGED
@@ -51,16 +51,20 @@ module Benchmark
|
|
51
51
|
# @return [Integer]
|
52
52
|
attr_accessor :confidence
|
53
53
|
|
54
|
+
# Silence output
|
55
|
+
# @return [Boolean]
|
56
|
+
attr_reader :quiet
|
57
|
+
|
58
|
+
# Suite
|
59
|
+
# @return [Benchmark::IPS::NoopSuite]
|
60
|
+
attr_reader :suite
|
61
|
+
|
54
62
|
# Instantiate the Benchmark::IPS::Job.
|
55
|
-
# @option opts [Benchmark::Suite] (nil) :suite Specify Benchmark::Suite.
|
56
|
-
# @option opts [Boolean] (false) :quiet Suppress the printing of information.
|
57
63
|
def initialize opts={}
|
58
|
-
@suite = opts[:suite] || nil
|
59
|
-
@stdout = opts[:quiet] ? nil : StdoutReport.new
|
60
64
|
@list = []
|
61
|
-
@compare = false
|
62
65
|
@run_single = false
|
63
66
|
@json_path = false
|
67
|
+
@compare = false
|
64
68
|
@held_path = nil
|
65
69
|
@held_results = nil
|
66
70
|
|
@@ -75,6 +79,8 @@ module Benchmark
|
|
75
79
|
# Default statistical model
|
76
80
|
@stats = :sd
|
77
81
|
@confidence = 95
|
82
|
+
|
83
|
+
self.quiet = false
|
78
84
|
end
|
79
85
|
|
80
86
|
# Job configuration options, set +@warmup+ and +@time+.
|
@@ -88,6 +94,20 @@ module Benchmark
|
|
88
94
|
@iterations = opts[:iterations] if opts[:iterations]
|
89
95
|
@stats = opts[:stats] if opts[:stats]
|
90
96
|
@confidence = opts[:confidence] if opts[:confidence]
|
97
|
+
self.quiet = opts[:quiet] if opts.key?(:quiet)
|
98
|
+
self.suite = opts[:suite]
|
99
|
+
end
|
100
|
+
|
101
|
+
def quiet=(val)
|
102
|
+
@stdout = reporter(quiet: val)
|
103
|
+
end
|
104
|
+
|
105
|
+
def suite=(suite)
|
106
|
+
@suite = suite || Benchmark::IPS::NoopSuite.new
|
107
|
+
end
|
108
|
+
|
109
|
+
def reporter(quiet:)
|
110
|
+
quiet ? NoopReport.new : StdoutReport.new
|
91
111
|
end
|
92
112
|
|
93
113
|
# Return true if job needs to be compared.
|
@@ -188,7 +208,7 @@ module Benchmark
|
|
188
208
|
end
|
189
209
|
|
190
210
|
def load_held_results
|
191
|
-
return unless @held_path && !File.zero?(@held_path)
|
211
|
+
return unless @held_path && File.exist?(@held_path) && !File.zero?(@held_path)
|
192
212
|
require "json"
|
193
213
|
@held_results = {}
|
194
214
|
JSON.load(IO.read(@held_path)).each do |result|
|
@@ -223,19 +243,19 @@ module Benchmark
|
|
223
243
|
|
224
244
|
def run
|
225
245
|
if @warmup && @warmup != 0 then
|
226
|
-
@stdout.start_warming
|
246
|
+
@stdout.start_warming
|
227
247
|
@iterations.times do
|
228
248
|
run_warmup
|
229
249
|
end
|
230
250
|
end
|
231
251
|
|
232
|
-
@stdout.start_running
|
252
|
+
@stdout.start_running
|
233
253
|
|
234
254
|
@iterations.times do |n|
|
235
255
|
run_benchmark
|
236
256
|
end
|
237
257
|
|
238
|
-
@stdout.footer
|
258
|
+
@stdout.footer
|
239
259
|
end
|
240
260
|
|
241
261
|
# Run warmup.
|
@@ -243,8 +263,8 @@ module Benchmark
|
|
243
263
|
@list.each do |item|
|
244
264
|
next if run_single? && @held_results && @held_results.key?(item.label)
|
245
265
|
|
246
|
-
@suite.warming item.label, @warmup
|
247
|
-
@stdout.warming item.label, @warmup
|
266
|
+
@suite.warming item.label, @warmup
|
267
|
+
@stdout.warming item.label, @warmup
|
248
268
|
|
249
269
|
Timing.clean_env
|
250
270
|
|
@@ -280,8 +300,8 @@ module Benchmark
|
|
280
300
|
item.call_times cycles
|
281
301
|
end
|
282
302
|
|
283
|
-
@stdout.warmup_stats warmup_time_us, @timing[item]
|
284
|
-
@suite.warmup_stats warmup_time_us, @timing[item]
|
303
|
+
@stdout.warmup_stats warmup_time_us, @timing[item]
|
304
|
+
@suite.warmup_stats warmup_time_us, @timing[item]
|
285
305
|
|
286
306
|
break if run_single?
|
287
307
|
end
|
@@ -292,8 +312,8 @@ module Benchmark
|
|
292
312
|
@list.each do |item|
|
293
313
|
next if run_single? && @held_results && @held_results.key?(item.label)
|
294
314
|
|
295
|
-
@suite.running item.label, @time
|
296
|
-
@stdout.running item.label, @time
|
315
|
+
@suite.running item.label, @time
|
316
|
+
@stdout.running item.label, @time
|
297
317
|
|
298
318
|
Timing.clean_env
|
299
319
|
|
@@ -334,8 +354,8 @@ module Benchmark
|
|
334
354
|
rep.show_total_time!
|
335
355
|
end
|
336
356
|
|
337
|
-
@stdout.add_report rep, caller(1).first
|
338
|
-
@suite.add_report rep, caller(1).first
|
357
|
+
@stdout.add_report rep, caller(1).first
|
358
|
+
@suite.add_report rep, caller(1).first
|
339
359
|
|
340
360
|
break if run_single?
|
341
361
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Benchmark
|
2
|
+
module IPS
|
3
|
+
class NoopSuite
|
4
|
+
def start_warming
|
5
|
+
end
|
6
|
+
|
7
|
+
def start_running
|
8
|
+
end
|
9
|
+
|
10
|
+
def footer
|
11
|
+
end
|
12
|
+
|
13
|
+
def warming(a, b)
|
14
|
+
end
|
15
|
+
|
16
|
+
def warmup_stats(a, b)
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_report(a, b)
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method :running, :warming
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/benchmark/ips/share.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/http'
|
2
4
|
require 'net/https'
|
3
5
|
require 'json'
|
@@ -5,7 +7,7 @@ require 'json'
|
|
5
7
|
module Benchmark
|
6
8
|
module IPS
|
7
9
|
class Share
|
8
|
-
DEFAULT_URL = "https://
|
10
|
+
DEFAULT_URL = "https://ips.fastruby.io"
|
9
11
|
def initialize(report, job)
|
10
12
|
@report = report
|
11
13
|
@job = job
|
data/lib/benchmark/ips.rb
CHANGED
@@ -5,8 +5,10 @@ require 'benchmark/ips/stats/stats_metric'
|
|
5
5
|
require 'benchmark/ips/stats/sd'
|
6
6
|
require 'benchmark/ips/stats/bootstrap'
|
7
7
|
require 'benchmark/ips/report'
|
8
|
+
require 'benchmark/ips/noop_suite'
|
8
9
|
require 'benchmark/ips/job/entry'
|
9
10
|
require 'benchmark/ips/job/stdout_report'
|
11
|
+
require 'benchmark/ips/job/noop_report'
|
10
12
|
require 'benchmark/ips/job'
|
11
13
|
|
12
14
|
# Performance benchmarking library
|
@@ -16,10 +18,10 @@ module Benchmark
|
|
16
18
|
module IPS
|
17
19
|
|
18
20
|
# Benchmark-ips Gem version.
|
19
|
-
VERSION = "2.
|
21
|
+
VERSION = "2.9.2"
|
20
22
|
|
21
23
|
# CODENAME of current version.
|
22
|
-
CODENAME = "
|
24
|
+
CODENAME = "Sleepy Sasquatch"
|
23
25
|
|
24
26
|
# Measure code in block, each code's benchmarked result will display in
|
25
27
|
# iteration per second with standard deviation in given time.
|
@@ -33,23 +35,14 @@ module Benchmark
|
|
33
35
|
time, warmup, quiet = args
|
34
36
|
end
|
35
37
|
|
36
|
-
suite = nil
|
37
|
-
|
38
38
|
sync, $stdout.sync = $stdout.sync, true
|
39
39
|
|
40
|
-
|
41
|
-
suite = Benchmark::Suite.current
|
42
|
-
end
|
43
|
-
|
44
|
-
quiet ||= (suite && suite.quiet?)
|
45
|
-
|
46
|
-
job = Job.new({:suite => suite,
|
47
|
-
:quiet => quiet
|
48
|
-
})
|
40
|
+
job = Job.new
|
49
41
|
|
50
42
|
job_opts = {}
|
51
43
|
job_opts[:time] = time unless time.nil?
|
52
44
|
job_opts[:warmup] = warmup unless warmup.nil?
|
45
|
+
job_opts[:quiet] = quiet unless quiet.nil?
|
53
46
|
|
54
47
|
job.config job_opts
|
55
48
|
|
data/test/test_benchmark_ips.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "minitest/autorun"
|
2
2
|
require "benchmark/ips"
|
3
3
|
require "stringio"
|
4
|
+
require "tmpdir"
|
4
5
|
|
5
6
|
class TestBenchmarkIPS < Minitest::Test
|
6
7
|
def setup
|
@@ -12,6 +13,13 @@ class TestBenchmarkIPS < Minitest::Test
|
|
12
13
|
$stdout = @old_stdout
|
13
14
|
end
|
14
15
|
|
16
|
+
def test_all_lib_files_are_included_in_manifest
|
17
|
+
project_root = File.expand_path('../..', __FILE__)
|
18
|
+
manifest = File.readlines("#{project_root}/Manifest.txt").map(&:chomp)
|
19
|
+
lib_files = Dir["#{project_root}/lib/**/*.rb"].map { |path| path.sub("#{project_root}/", '') }
|
20
|
+
lib_files.each { |lib_file| assert_includes manifest, lib_file }
|
21
|
+
end
|
22
|
+
|
15
23
|
def test_kwargs
|
16
24
|
Benchmark.ips(:time => 1, :warmup => 1, :quiet => false) do |x|
|
17
25
|
x.report("sleep 0.25") { sleep(0.25) }
|
@@ -53,6 +61,39 @@ class TestBenchmarkIPS < Minitest::Test
|
|
53
61
|
end
|
54
62
|
|
55
63
|
assert $stdout.string.size.zero?
|
64
|
+
|
65
|
+
Benchmark.ips do |x|
|
66
|
+
x.quiet = true
|
67
|
+
x.report("operation") { 100 * 100 }
|
68
|
+
end
|
69
|
+
|
70
|
+
assert $stdout.string.size.zero?
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_quiet_option_override
|
74
|
+
Benchmark.ips(quiet: true) do |x|
|
75
|
+
x.quiet = false
|
76
|
+
x.report("operation") { 100 * 100 }
|
77
|
+
end
|
78
|
+
|
79
|
+
assert $stdout.string.size > 0
|
80
|
+
$stdout.truncate(0)
|
81
|
+
|
82
|
+
Benchmark.ips(quiet: true) do |x|
|
83
|
+
x.config(quiet: false)
|
84
|
+
x.report("operation") { 100 * 100 }
|
85
|
+
end
|
86
|
+
|
87
|
+
assert $stdout.string.size > 0
|
88
|
+
$stdout.truncate(0)
|
89
|
+
|
90
|
+
Benchmark.ips(quiet: true) do |x|
|
91
|
+
# Calling config should not make quiet option overridden when no specified
|
92
|
+
x.config({})
|
93
|
+
x.report("operation") { 100 * 100 }
|
94
|
+
end
|
95
|
+
|
96
|
+
assert $stdout.string.size.zero?
|
56
97
|
end
|
57
98
|
|
58
99
|
def test_ips
|
@@ -116,6 +157,21 @@ class TestBenchmarkIPS < Minitest::Test
|
|
116
157
|
assert_equal [:warming, :warmup_stats, :running, :add_report], suite.calls
|
117
158
|
end
|
118
159
|
|
160
|
+
def test_ips_config_suite_by_accsr
|
161
|
+
suite = Struct.new(:calls) do
|
162
|
+
def method_missing(method, *args)
|
163
|
+
calls << method
|
164
|
+
end
|
165
|
+
end.new([])
|
166
|
+
|
167
|
+
Benchmark.ips(0.1, 0.1) do |x|
|
168
|
+
x.suite = suite
|
169
|
+
x.report("job") {}
|
170
|
+
end
|
171
|
+
|
172
|
+
assert_equal [:warming, :warmup_stats, :running, :add_report], suite.calls
|
173
|
+
end
|
174
|
+
|
119
175
|
def test_ips_defaults
|
120
176
|
report = Benchmark.ips do |x|
|
121
177
|
x.report("sleep 0.25") { sleep(0.25) }
|
@@ -182,4 +238,17 @@ class TestBenchmarkIPS < Minitest::Test
|
|
182
238
|
assert data[0]["ips"]
|
183
239
|
assert data[0]["stddev"]
|
184
240
|
end
|
241
|
+
|
242
|
+
def test_hold!
|
243
|
+
temp_file_name = Dir::Tmpname.create(["benchmark-ips", ".tmp"]) { }
|
244
|
+
|
245
|
+
Benchmark.ips(:time => 0.001, :warmup => 0.001) do |x|
|
246
|
+
x.report("operation") { 100 * 100 }
|
247
|
+
x.report("operation2") { 100 * 100 }
|
248
|
+
x.hold! temp_file_name
|
249
|
+
end
|
250
|
+
|
251
|
+
assert File.exist?(temp_file_name)
|
252
|
+
File.unlink(temp_file_name)
|
253
|
+
end
|
185
254
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmark-ips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -77,7 +77,9 @@ files:
|
|
77
77
|
- lib/benchmark/ips.rb
|
78
78
|
- lib/benchmark/ips/job.rb
|
79
79
|
- lib/benchmark/ips/job/entry.rb
|
80
|
+
- lib/benchmark/ips/job/noop_report.rb
|
80
81
|
- lib/benchmark/ips/job/stdout_report.rb
|
82
|
+
- lib/benchmark/ips/noop_suite.rb
|
81
83
|
- lib/benchmark/ips/report.rb
|
82
84
|
- lib/benchmark/ips/share.rb
|
83
85
|
- lib/benchmark/ips/stats/bootstrap.rb
|
@@ -107,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: '0'
|
109
111
|
requirements: []
|
110
|
-
rubygems_version: 3.1.
|
112
|
+
rubygems_version: 3.1.4
|
111
113
|
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: An iterations per second enhancement to Benchmark.
|