benchmark-ips 2.11.0 → 2.13.0
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.md +5 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/examples/advanced.rb +0 -0
- data/examples/hold.rb +0 -0
- data/examples/save.rb +0 -0
- data/lib/benchmark/compare.rb +0 -0
- data/lib/benchmark/ips/job/entry.rb +0 -0
- data/lib/benchmark/ips/job/multi_report.rb +67 -0
- data/lib/benchmark/ips/job/{stdout_report.rb → stream_report.rb} +11 -9
- data/lib/benchmark/ips/job.rb +22 -23
- data/lib/benchmark/ips/report.rb +0 -0
- data/lib/benchmark/ips/share.rb +0 -0
- data/lib/benchmark/ips/stats/bootstrap.rb +0 -0
- data/lib/benchmark/ips/stats/sd.rb +0 -0
- data/lib/benchmark/ips/stats/stats_metric.rb +0 -0
- data/lib/benchmark/ips.rb +12 -18
- data/lib/benchmark/timing.rb +1 -1
- metadata +4 -5
- data/lib/benchmark/ips/job/noop_report.rb +0 -27
- data/lib/benchmark/ips/noop_suite.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc54b5cf0d24b23822486adf5759cceeefbef9a60c780454318472f4739050f6
|
4
|
+
data.tar.gz: ea2764b060fef8c931c4636eb63e84d48f98242f7335648fed8b82b2fdeb053d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72ed2d83e42b125ca812aa1e79113be4726f8bb2e0ca4cb784dddc1d70eddc16c088308e1214cba9f7ec83ad77d89d9ae544b7892b6abac8f3e0b88d1617e7a8
|
7
|
+
data.tar.gz: 94bda95d5db4a9032692e732a04eb3147ad3839b0e674f13d676b1fdf2130a8f0a269e6f5817791683965bf86662be10c7e5476e0539d71916b6b35562ac7806
|
data/History.md
CHANGED
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/examples/advanced.rb
CHANGED
File without changes
|
data/examples/hold.rb
CHANGED
File without changes
|
data/examples/save.rb
CHANGED
File without changes
|
data/lib/benchmark/compare.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Benchmark
|
2
|
+
module IPS
|
3
|
+
class Job
|
4
|
+
class MultiReport
|
5
|
+
# @returns out [Array<StreamReport>] list of reports to send output
|
6
|
+
attr_accessor :out
|
7
|
+
|
8
|
+
def empty?
|
9
|
+
@out.empty?
|
10
|
+
end
|
11
|
+
|
12
|
+
def quiet?
|
13
|
+
@out.none? { |rpt| rpt.kind_of?(StreamReport) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def quiet!
|
17
|
+
@out.delete_if { |rpt| rpt.kind_of?(StreamReport) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param report [StreamReport] report to accept input?
|
21
|
+
def <<(report)
|
22
|
+
if report.kind_of?(MultiReport)
|
23
|
+
self << report.out
|
24
|
+
elsif report.kind_of?(Enumerable)
|
25
|
+
@out += report
|
26
|
+
elsif report
|
27
|
+
@out << report
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param out [Array<StreamReport>] list of reports to send output
|
32
|
+
def initialize(out = nil)
|
33
|
+
@out = []
|
34
|
+
self << out
|
35
|
+
end
|
36
|
+
|
37
|
+
def start_warming
|
38
|
+
@out.each { |o| o.start_warming if o.respond_to?(:start_warming) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def warming(label, warmup)
|
42
|
+
@out.each { |o| o.warming(label, warmup) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def warmup_stats(warmup_time_us, timing)
|
46
|
+
@out.each { |o| o.warmup_stats(warmup_time_us, timing) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_running
|
50
|
+
@out.each { |o| o.start_running if o.respond_to?(:start_running) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def running(label, warmup)
|
54
|
+
@out.each { |o| o.running(label, warmup) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_report(item, caller)
|
58
|
+
@out.each { |o| o.add_report(item, caller) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def footer
|
62
|
+
@out.each { |o| o.footer if o.respond_to?(:footer) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,43 +1,45 @@
|
|
1
1
|
module Benchmark
|
2
2
|
module IPS
|
3
3
|
class Job
|
4
|
-
class
|
5
|
-
def initialize
|
4
|
+
class StreamReport
|
5
|
+
def initialize(stream = $stdout)
|
6
6
|
@last_item = nil
|
7
|
+
@out = stream
|
7
8
|
end
|
8
9
|
|
9
10
|
def start_warming
|
10
|
-
|
11
|
+
@out.puts RUBY_DESCRIPTION
|
12
|
+
@out.puts "Warming up --------------------------------------"
|
11
13
|
end
|
12
14
|
|
13
15
|
def start_running
|
14
|
-
|
16
|
+
@out.puts "Calculating -------------------------------------"
|
15
17
|
end
|
16
18
|
|
17
19
|
def warming(label, _warmup)
|
18
|
-
|
20
|
+
@out.print rjust(label)
|
19
21
|
end
|
20
22
|
|
21
23
|
def warmup_stats(_warmup_time_us, timing)
|
22
24
|
case format
|
23
25
|
when :human
|
24
|
-
|
26
|
+
@out.printf "%s i/100ms\n", Helpers.scale(timing)
|
25
27
|
else
|
26
|
-
|
28
|
+
@out.printf "%10d i/100ms\n", timing
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
alias_method :running, :warming
|
31
33
|
|
32
34
|
def add_report(item, caller)
|
33
|
-
|
35
|
+
@out.puts " #{item.body}"
|
34
36
|
@last_item = item
|
35
37
|
end
|
36
38
|
|
37
39
|
def footer
|
38
40
|
return unless @last_item
|
39
41
|
footer = @last_item.stats.footer
|
40
|
-
|
42
|
+
@out.puts footer.rjust(40) if footer
|
41
43
|
end
|
42
44
|
|
43
45
|
private
|
data/lib/benchmark/ips/job.rb
CHANGED
@@ -53,11 +53,15 @@ module Benchmark
|
|
53
53
|
|
54
54
|
# Silence output
|
55
55
|
# @return [Boolean]
|
56
|
-
|
56
|
+
def quiet
|
57
|
+
@out.quiet?
|
58
|
+
end
|
57
59
|
|
58
60
|
# Suite
|
59
|
-
# @return [Benchmark::IPS::
|
60
|
-
|
61
|
+
# @return [Benchmark::IPS::MultiReport]
|
62
|
+
def suite
|
63
|
+
@out
|
64
|
+
end
|
61
65
|
|
62
66
|
# Instantiate the Benchmark::IPS::Job.
|
63
67
|
def initialize opts={}
|
@@ -81,7 +85,7 @@ module Benchmark
|
|
81
85
|
@stats = :sd
|
82
86
|
@confidence = 95
|
83
87
|
|
84
|
-
|
88
|
+
@out = MultiReport.new(StreamReport.new)
|
85
89
|
end
|
86
90
|
|
87
91
|
# Job configuration options, set +@warmup+ and +@time+.
|
@@ -91,24 +95,23 @@ module Benchmark
|
|
91
95
|
def config opts
|
92
96
|
@warmup = opts[:warmup] if opts[:warmup]
|
93
97
|
@time = opts[:time] if opts[:time]
|
94
|
-
@suite = opts[:suite] if opts[:suite]
|
95
98
|
@iterations = opts[:iterations] if opts[:iterations]
|
96
99
|
@stats = opts[:stats] if opts[:stats]
|
97
100
|
@confidence = opts[:confidence] if opts[:confidence]
|
98
101
|
self.quiet = opts[:quiet] if opts.key?(:quiet)
|
99
|
-
self.suite = opts[:suite]
|
102
|
+
self.suite = opts[:suite] if opts[:suite]
|
100
103
|
end
|
101
104
|
|
102
105
|
def quiet=(val)
|
103
|
-
|
106
|
+
if val # remove instances of StreamReport
|
107
|
+
@out.quiet!
|
108
|
+
else # ensure there is an instance of StreamReport
|
109
|
+
@out << StreamReport.new if @out.quiet?
|
110
|
+
end
|
104
111
|
end
|
105
112
|
|
106
113
|
def suite=(suite)
|
107
|
-
@
|
108
|
-
end
|
109
|
-
|
110
|
-
def reporter(quiet:)
|
111
|
-
quiet ? NoopReport.new : StdoutReport.new
|
114
|
+
@out << suite
|
112
115
|
end
|
113
116
|
|
114
117
|
# Return true if job needs to be compared.
|
@@ -245,19 +248,19 @@ module Benchmark
|
|
245
248
|
|
246
249
|
def run
|
247
250
|
if @warmup && @warmup != 0 then
|
248
|
-
@
|
251
|
+
@out.start_warming
|
249
252
|
@iterations.times do
|
250
253
|
run_warmup
|
251
254
|
end
|
252
255
|
end
|
253
256
|
|
254
|
-
@
|
257
|
+
@out.start_running
|
255
258
|
|
256
259
|
@iterations.times do |n|
|
257
260
|
run_benchmark
|
258
261
|
end
|
259
262
|
|
260
|
-
@
|
263
|
+
@out.footer
|
261
264
|
end
|
262
265
|
|
263
266
|
# Run warmup.
|
@@ -265,8 +268,7 @@ module Benchmark
|
|
265
268
|
@list.each do |item|
|
266
269
|
next if run_single? && @held_results && @held_results.key?(item.label)
|
267
270
|
|
268
|
-
@
|
269
|
-
@stdout.warming item.label, @warmup
|
271
|
+
@out.warming item.label, @warmup
|
270
272
|
|
271
273
|
Timing.clean_env
|
272
274
|
|
@@ -300,8 +302,7 @@ module Benchmark
|
|
300
302
|
item.call_times cycles
|
301
303
|
end
|
302
304
|
|
303
|
-
@
|
304
|
-
@suite.warmup_stats warmup_time_us, @timing[item]
|
305
|
+
@out.warmup_stats warmup_time_us, @timing[item]
|
305
306
|
|
306
307
|
break if run_single?
|
307
308
|
end
|
@@ -312,8 +313,7 @@ module Benchmark
|
|
312
313
|
@list.each do |item|
|
313
314
|
next if run_single? && @held_results && @held_results.key?(item.label)
|
314
315
|
|
315
|
-
@
|
316
|
-
@stdout.running item.label, @time
|
316
|
+
@out.running item.label, @time
|
317
317
|
|
318
318
|
Timing.clean_env
|
319
319
|
|
@@ -355,8 +355,7 @@ module Benchmark
|
|
355
355
|
rep.show_total_time!
|
356
356
|
end
|
357
357
|
|
358
|
-
@
|
359
|
-
@suite.add_report rep, caller(1).first
|
358
|
+
@out.add_report rep, caller(1).first
|
360
359
|
|
361
360
|
break if run_single?
|
362
361
|
end
|
data/lib/benchmark/ips/report.rb
CHANGED
File without changes
|
data/lib/benchmark/ips/share.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/benchmark/ips.rb
CHANGED
@@ -5,10 +5,9 @@ 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'
|
9
8
|
require 'benchmark/ips/job/entry'
|
10
|
-
require 'benchmark/ips/job/
|
11
|
-
require 'benchmark/ips/job/
|
9
|
+
require 'benchmark/ips/job/stream_report'
|
10
|
+
require 'benchmark/ips/job/multi_report'
|
12
11
|
require 'benchmark/ips/job'
|
13
12
|
|
14
13
|
# Performance benchmarking library
|
@@ -18,10 +17,10 @@ module Benchmark
|
|
18
17
|
module IPS
|
19
18
|
|
20
19
|
# Benchmark-ips Gem version.
|
21
|
-
VERSION = "2.
|
20
|
+
VERSION = "2.13.0"
|
22
21
|
|
23
22
|
# CODENAME of current version.
|
24
|
-
CODENAME = "
|
23
|
+
CODENAME = "Long Awaited"
|
25
24
|
|
26
25
|
# Measure code in block, each code's benchmarked result will display in
|
27
26
|
# iteration per second with standard deviation in given time.
|
@@ -83,20 +82,15 @@ module Benchmark
|
|
83
82
|
end
|
84
83
|
|
85
84
|
module Helpers
|
85
|
+
SUFFIXES = ['', 'k', 'M', 'B', 'T', 'Q'].freeze
|
86
|
+
|
86
87
|
def scale(value)
|
87
|
-
scale = (Math.log10(value) / 3).to_i
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
when 5; 'Q'
|
94
|
-
else
|
95
|
-
# < 1000 or > 10^15, no scale or suffix
|
96
|
-
scale = 0
|
97
|
-
' '
|
98
|
-
end
|
99
|
-
"%10.3f#{suffix}" % (value.to_f / (1000 ** scale))
|
88
|
+
scale = (Math.log10(value) / 3).to_i
|
89
|
+
scale = 0 if scale < 0 || scale >= SUFFIXES.size
|
90
|
+
suffix = SUFFIXES[scale]
|
91
|
+
scaled_value = value.to_f / (1000 ** scale)
|
92
|
+
|
93
|
+
"%10.3f#{suffix}" % scaled_value
|
100
94
|
end
|
101
95
|
module_function :scale
|
102
96
|
end
|
data/lib/benchmark/timing.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmark-ips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Phoenix
|
@@ -59,9 +59,8 @@ files:
|
|
59
59
|
- lib/benchmark/ips.rb
|
60
60
|
- lib/benchmark/ips/job.rb
|
61
61
|
- lib/benchmark/ips/job/entry.rb
|
62
|
-
- lib/benchmark/ips/job/
|
63
|
-
- lib/benchmark/ips/job/
|
64
|
-
- lib/benchmark/ips/noop_suite.rb
|
62
|
+
- lib/benchmark/ips/job/multi_report.rb
|
63
|
+
- lib/benchmark/ips/job/stream_report.rb
|
65
64
|
- lib/benchmark/ips/report.rb
|
66
65
|
- lib/benchmark/ips/share.rb
|
67
66
|
- lib/benchmark/ips/stats/bootstrap.rb
|
@@ -89,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
88
|
- !ruby/object:Gem::Version
|
90
89
|
version: '0'
|
91
90
|
requirements: []
|
92
|
-
rubygems_version: 3.3.
|
91
|
+
rubygems_version: 3.3.7
|
93
92
|
signing_key:
|
94
93
|
specification_version: 4
|
95
94
|
summary: A iterations per second enhancement to Benchmark.
|
@@ -1,27 +0,0 @@
|
|
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
|
@@ -1,25 +0,0 @@
|
|
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
|