benchmark-ips 2.9.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bec7b23527f8a5f331788f9de05073eede35e26bbc5a6b81c05a609d964c0ff
4
- data.tar.gz: aa8ba81457df018d94262d0eb722870d34406204d02a61b0ad1aa398fa2903ff
3
+ metadata.gz: 0516f3e1e35f43a8fe32a6f32357aa124478ba54228ffe57d928cfc1231851bc
4
+ data.tar.gz: d62da6a6c1d2696b7667bd125ffe6bb2c33b3d61da5c393e729d7ca8a3d70ee7
5
5
  SHA512:
6
- metadata.gz: 0b8c313bd722fd52229c280d4d566fb9e246b8ae4253a0f508a5b9ca7fffd35cd780cc6c9aa96894733ee87d0df844feae530c10dbf38989cb07367094ce19f3
7
- data.tar.gz: 037a07ffd3f129a06a68b5c53617379a9c7e3397fc9b02a961c7e7bb9b566f3ad0b423a43b3b5ed3e40f9edfac4f6eed810bc231c8e6d1398afaa65730d62946
6
+ metadata.gz: b644d293980f1ac9e3158abbe4f2c9d44d23185878edb9cb3861f3ca4f6837d557f89f8eb19bfcc42a45f53f3d112f2fe3ab22fc85a9633ede7e678b5fb90336
7
+ data.tar.gz: afe9972cdecdb2f42d4946afbac3d02cb3ead3a3d47a804960026ea77487cf885f6ddd7368edb13c522ee11e251599bf953d3d9a8172411c10e7259f7e9352b2
@@ -1,26 +1,47 @@
1
- === 2.9.0 / 2021-05-21
1
+ ### 2.10.0 / 2022-02-17
2
+
3
+ * Feature
4
+ * Adds :order option to compare, with new `:baseline` order which compares all
5
+ variations against the first option benchmarked.
6
+
7
+ ### 2.9.3 / 2022-01-25
8
+
9
+ * Bug fix
10
+ * All warmups and benchmarks must run at least once
11
+
12
+ ### 2.9.2 / 2021-10-10
13
+
14
+ * Bug fix
15
+ * Fix a problem with certain configs of quiet mode
16
+
17
+ ### 2.9.1 / 2021-05-24
18
+
19
+ * Bug fix
20
+ * Include all files in gem
21
+
22
+ ### 2.9.0 / 2021-05-21
2
23
 
3
24
  * Features
4
25
  * Suite can now be set via an accessor
5
26
  * Default SHARE_URL is now `ips.fastruby.io`, operated by Ombu Labs.
6
27
 
7
- === 2.8.4 / 2020-12-03
28
+ ### 2.8.4 / 2020-12-03
8
29
 
9
30
  * Bug fix
10
31
  * Fixed hold! when results file does not exist.
11
32
 
12
- === 2.8.3 / 2020-08-28
33
+ ### 2.8.3 / 2020-08-28
13
34
 
14
35
  * Bug fix
15
36
  * Fixed inaccuracy caused by integer overflows.
16
37
 
17
- === 2.8.2 / 2020-05-04
38
+ ### 2.8.2 / 2020-05-04
18
39
 
19
40
  * Bug fix
20
41
  * Fixed problems with Manifest.txt.
21
42
  * Empty interim results files are ignored.
22
43
 
23
- === 2.8.0 / 2020-05-01
44
+ ### 2.8.0 / 2020-05-01
24
45
 
25
46
  * Feature
26
47
  * Allow running with empty ips block.
@@ -33,16 +54,16 @@
33
54
  * Added some RDoc docs.
34
55
  * Added some examples in examples/
35
56
 
36
- === 2.7.2 / 2016-08-18
57
+ ### 2.7.2 / 2016-08-18
37
58
 
38
59
  * 1 bug fix:
39
60
  * Restore old accessors. Fixes #76
40
61
 
41
- === 2.7.1 / 2016-08-08
62
+ ### 2.7.1 / 2016-08-08
42
63
 
43
64
  Add missing files
44
65
 
45
- === 2.7.0 / 2016-08-05
66
+ ### 2.7.0 / 2016-08-05
46
67
 
47
68
  * 1 minor features:
48
69
  * Add support for confidence intervals
@@ -59,9 +80,9 @@ Add missing files
59
80
  * Merge pull request #67 from benoittgt/master
60
81
  * Merge pull request #69 from chrisseaton/kalibera-confidence-intervals
61
82
 
62
- === MISSING 2.6.0 and 2.6.1
83
+ ### MISSING 2.6.0 and 2.6.1
63
84
 
64
- === 2.5.0 / 2016-02-14
85
+ ### 2.5.0 / 2016-02-14
65
86
 
66
87
  * 1 minor feature:
67
88
  * Add iterations option.
@@ -73,12 +94,12 @@ Add missing files
73
94
  * Merge pull request #58 from chrisseaton/iterations
74
95
  * Merge pull request #60 from chrisseaton/significance
75
96
 
76
- === 2.4.1 / 2016-02-12
97
+ ### 2.4.1 / 2016-02-12
77
98
 
78
99
  * 1 bug fix:
79
100
  * Add missing files to gem
80
101
 
81
- === 2.4.0 / 2016-02-12
102
+ ### 2.4.0 / 2016-02-12
82
103
 
83
104
  * 1 minor features
84
105
  * Add support for hold! and independent invocations.
@@ -113,7 +134,7 @@ Add missing files
113
134
  * Merge pull request #56 from chrisseaton/independence
114
135
  * Merge pull request #57 from chrisseaton/tighten-loop
115
136
 
116
- === 2.3.0 / 2015-07-20
137
+ ### 2.3.0 / 2015-07-20
117
138
 
118
139
  * 2 minor features:
119
140
  * Support keyword arguments
@@ -127,7 +148,7 @@ Add missing files
127
148
  * Merge pull request #42 from kbrock/newer_travis
128
149
  * Merge pull request #43 from kbrock/non_to_s_labels
129
150
 
130
- === 2.2.0 / 2015-05-09
151
+ ### 2.2.0 / 2015-05-09
131
152
 
132
153
  * 1 minor features:
133
154
  * Fix quiet mode
@@ -151,7 +172,7 @@ Add missing files
151
172
  * Merge pull request #29 from JuanitoFatas/feature/json-export
152
173
  * Merge pull request #26 from JuanitoFatas/feature/takes-symbol-as-report-parameter
153
174
 
154
- === 2.1.1 / 2015-01-12
175
+ ### 2.1.1 / 2015-01-12
155
176
 
156
177
  * 1 minor fix:
157
178
  * Don't send label through printf so that % work directly
@@ -165,7 +186,7 @@ Add missing files
165
186
  * 1 PR merged:
166
187
  * Merge pull request #24 from zzak/simple-format-result-description
167
188
 
168
- === 2.1.0 / 2014-11-10
189
+ ### 2.1.0 / 2014-11-10
169
190
 
170
191
  * Documentation changes:
171
192
  * Many documentation fixes by Juanito Fatas!
@@ -176,7 +197,7 @@ Add missing files
176
197
  * Formatting of large values improved (human vs raw mode)
177
198
  * Contributed by Charles Oliver Nutter
178
199
 
179
- === 2.0.0 / 2014-06-18
200
+ ### 2.0.0 / 2014-06-18
180
201
 
181
202
  * The 'Davy Stevenson' release!
182
203
  * Codename: Springtime Hummingbird Dance
@@ -194,7 +215,7 @@ Add missing files
194
215
  * Zachary Scott
195
216
  * schneems (Richard Schneeman)
196
217
 
197
- === 1.0.0 / 2012-03-23
218
+ ### 1.0.0 / 2012-03-23
198
219
 
199
220
  * 1 major enhancement
200
221
 
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Evan Phoenix
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -254,27 +254,3 @@ After checking out the source, run:
254
254
  This task will install any missing dependencies, run the tests/specs,
255
255
  and generate the RDoc.
256
256
 
257
- ## LICENSE:
258
-
259
- (The MIT License)
260
-
261
- Copyright (c) 2015 Evan Phoenix
262
-
263
- Permission is hereby granted, free of charge, to any person obtaining
264
- a copy of this software and associated documentation files (the
265
- 'Software'), to deal in the Software without restriction, including
266
- without limitation the rights to use, copy, modify, merge, publish,
267
- distribute, sublicense, and/or sell copies of the Software, and to
268
- permit persons to whom the Software is furnished to do so, subject to
269
- the following conditions:
270
-
271
- The above copyright notice and this permission notice shall be
272
- included in all copies or substantial portions of the Software.
273
-
274
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
275
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
276
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
277
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
278
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
279
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
280
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'benchmark/ips'
4
+
5
+ Benchmark.ips do |x|
6
+
7
+ # Use bootstrap confidence intervals
8
+ x.stats = :bootstrap
9
+
10
+ # Set confidence to 95%
11
+ x.confidence = 95
12
+
13
+ # Run multiple iterations for better warmup
14
+ x.iterations = 3
15
+
16
+ x.report("mul") { 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 }
17
+ x.report("pow") { 2 ** 8 }
18
+
19
+ x.compare!
20
+ end
data/examples/hold.rb ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # example to explain hold! usage https://github.com/evanphx/benchmark-ips/issues/85
3
+ # The hold! feature expects to be run twice, generally with different Rubys.
4
+ # hold! can also be used to compare modules changes which impact the run time
5
+ # RUN_1: ruby examples/hold.rb
6
+ # Warming up --------------------------------------
7
+ # without 172.168k i/100ms
8
+ # Calculating -------------------------------------
9
+ # without 2.656M (± 3.3%) i/s - 13.429M in 5.062098s
10
+ #
11
+ # RUN_2: WITH_MODULE=true ruby examples/hold.rb
12
+ # Warming up --------------------------------------
13
+ # with 92.087k i/100ms
14
+ # Calculating -------------------------------------
15
+ # with 1.158M (± 1.4%) i/s - 5.801M in 5.010084s
16
+ #
17
+ # Comparison:
18
+ # without: 2464721.3 i/s
19
+ # with: 1158179.6 i/s - 2.13x slower
20
+ require 'benchmark/ips'
21
+
22
+ Benchmark.ips do |x|
23
+ x.report('without') do
24
+ 'Bruce'.inspect
25
+ end
26
+
27
+ if ENV['WITH_MODULE'] == 'true'
28
+ class String
29
+ def inspect
30
+ result = %w[Bruce Wayne is Batman]
31
+ result.join(' ')
32
+ end
33
+ end
34
+ end
35
+
36
+ x.report('with') do
37
+ 'Bruce'.inspect
38
+ end
39
+ x.hold! 'temp_results'
40
+ x.compare!
41
+ end
data/examples/save.rb ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # example to explain save!
4
+ # The save! feature expects to be run twice, generally with different Rubys.
5
+ # save! can also be used to compare modules changes which impact the run time
6
+ #
7
+ # If you're comparing ruby versions, Just use the version in the label
8
+ #
9
+ # x.report("ruby #{RUBY_VERSION}") { 'Bruce'.inspect }
10
+ #
11
+ # Or use a hash
12
+ #
13
+ # x.report("version" => RUBY_VERSION, "method" => 'bruce') { 'Bruce'.inspect }
14
+ #
15
+ # RUN_1: SAVE_FILE='run1.out' ruby examples/hold.rb
16
+ # Warming up --------------------------------------
17
+ # without 172.168k i/100ms
18
+ # Calculating -------------------------------------
19
+ # without 2.656M (± 3.3%) i/s - 13.429M in 5.062098s
20
+ #
21
+ # RUN_2: SAVE_FILE='run1.out' WITH_MODULE=true ruby examples/hold.rb
22
+ # Warming up --------------------------------------
23
+ # with 92.087k i/100ms
24
+ # Calculating -------------------------------------
25
+ # with 1.158M (± 1.4%) i/s - 5.801M in 5.010084s
26
+ #
27
+ # Comparison:
28
+ # without: 2464721.3 i/s
29
+ # with: 1158179.6 i/s - 2.13x slower
30
+ # CLEANUP: rm run1.out
31
+
32
+ require 'benchmark/ips'
33
+
34
+ Benchmark.ips do |x|
35
+ x.report(ENV['WITH_MODULE'] == 'true' ? 'with' : 'without') do
36
+ 'Bruce'.inspect
37
+ end
38
+
39
+ if ENV['WITH_MODULE'] == 'true'
40
+ class String
41
+ def inspect
42
+ result = %w[Bruce Wayne is Batman]
43
+ result.join(' ')
44
+ end
45
+ end
46
+ end
47
+
48
+ x.save! ENV['SAVE_FILE'] if ENV['SAVE_FILE']
49
+ x.compare!
50
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'benchmark/ips'
4
+
5
+ Benchmark.ips do |x|
6
+
7
+ # Configure the number of seconds used during
8
+ # the warmup phase and calculation phase
9
+ x.config(:time => 5, :warmup => 2)
10
+
11
+ # These parameters can also be configured this way
12
+ x.time = 5
13
+ x.warmup = 2
14
+
15
+ # Typical mode, runs the block as many times as it can
16
+ x.report("addition") { 1 + 2 }
17
+
18
+ # To reduce overhead, the number of iterations is passed in
19
+ # and the block must run the code the specific number of times.
20
+ # Used for when the workload is very small and any overhead
21
+ # introduces incorrectable errors.
22
+ x.report(:addition2) do |times|
23
+ i = 0
24
+ while i < times
25
+ 1 + 2
26
+ i += 1
27
+ end
28
+ end
29
+
30
+ # To reduce overhead even more, grafts the code given into
31
+ # the loop that performs the iterations internally to reduce
32
+ # overhead. Typically not needed, use the |times| form instead.
33
+ x.report("addition3", "1 + 2")
34
+
35
+ # Really long labels should be formatted correctly
36
+ x.report("addition-test-long-label") { 1 + 2 }
37
+
38
+ x.compare!
39
+ end
40
+
41
+ puts <<-EOD
42
+ Typical results will show addition2 & addition3 to be the most performant, and
43
+ they should perform reasonably similarly. You should see addition and
44
+ addition-test-long-label to perform very similarly to each other (as they are
45
+ running the same test, just with different labels), and they should both run in
46
+ the neighborhood of 3.5 times slower than addition2 and addition3."
47
+ EOD
@@ -26,31 +26,67 @@ module Benchmark
26
26
  # Reduce using to_proc: 247295.4 i/s - 1.13x slower
27
27
  #
28
28
  # Besides regular Calculating report, this will also indicates which one is slower.
29
+ #
30
+ # +x.compare!+ also takes an +order: :baseline+ option.
31
+ #
32
+ # Example:
33
+ # > Benchmark.ips do |x|
34
+ # x.report('Reduce using block') { [*1..10].reduce { |sum, n| sum + n } }
35
+ # x.report('Reduce using tag') { [*1..10].reduce(:+) }
36
+ # x.report('Reduce using to_proc') { [*1..10].reduce(&:+) }
37
+ # x.compare!(order: :baseline)
38
+ # end
39
+ #
40
+ # Calculating -------------------------------------
41
+ # Reduce using block 886.202k (± 2.2%) i/s - 4.521M in 5.103774s
42
+ # Reduce using tag 1.821M (± 1.6%) i/s - 9.111M in 5.004183s
43
+ # Reduce using to_proc 895.948k (± 1.6%) i/s - 4.528M in 5.055368s
44
+ #
45
+ # Comparison:
46
+ # Reduce using block: 886202.5 i/s
47
+ # Reduce using tag: 1821055.0 i/s - 2.05x (± 0.00) faster
48
+ # Reduce using to_proc: 895948.1 i/s - same-ish: difference falls within error
49
+ #
50
+ # The first report is considered the baseline against which other reports are compared.
29
51
  module Compare
30
52
 
31
53
  # Compare between reports, prints out facts of each report:
32
54
  # runtime, comparative speed difference.
33
55
  # @param entries [Array<Report::Entry>] Reports to compare.
34
- def compare(*entries)
56
+ def compare(*entries, order: :fastest)
35
57
  return if entries.size < 2
36
58
 
37
- sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
38
-
39
- best = sorted.shift
59
+ case order
60
+ when :baseline
61
+ baseline = entries.shift
62
+ sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
63
+ when :fastest
64
+ sorted = entries.sort_by{ |e| e.stats.central_tendency }.reverse
65
+ baseline = sorted.shift
66
+ else
67
+ raise ArgumentError, "Unknwon order: #{order.inspect}"
68
+ end
40
69
 
41
70
  $stdout.puts "\nComparison:"
42
71
 
43
- $stdout.printf "%20s: %10.1f i/s\n", best.label.to_s, best.stats.central_tendency
72
+ $stdout.printf "%20s: %10.1f i/s\n", baseline.label.to_s, baseline.stats.central_tendency
44
73
 
45
74
  sorted.each do |report|
46
75
  name = report.label.to_s
47
76
 
48
77
  $stdout.printf "%20s: %10.1f i/s - ", name, report.stats.central_tendency
49
78
 
50
- if report.stats.overlaps?(best.stats)
79
+ if report.stats.overlaps?(baseline.stats)
51
80
  $stdout.print "same-ish: difference falls within error"
81
+ elsif report.stats.central_tendency > baseline.stats.central_tendency
82
+ speedup, error = report.stats.speedup(baseline.stats)
83
+ $stdout.printf "%.2fx ", speedup
84
+ if error
85
+ $stdout.printf " (± %.2f)", error
86
+ end
87
+ $stdout.print " faster"
52
88
  else
53
- slowdown, error = report.stats.slowdown(best.stats)
89
+ slowdown, error = report.stats.slowdown(baseline.stats)
54
90
  $stdout.printf "%.2fx ", slowdown
55
91
  if error
56
92
  $stdout.printf " (± %.2f)", error
@@ -61,7 +97,7 @@ module Benchmark
61
97
  $stdout.puts
62
98
  end
63
99
 
64
- footer = best.stats.footer
100
+ footer = baseline.stats.footer
65
101
  $stdout.puts footer.rjust(40) if footer
66
102
 
67
103
  $stdout.puts
File without changes
@@ -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
File without changes
@@ -65,6 +65,7 @@ module Benchmark
65
65
  @run_single = false
66
66
  @json_path = false
67
67
  @compare = false
68
+ @compare_order = :fastest
68
69
  @held_path = nil
69
70
  @held_results = nil
70
71
 
@@ -79,6 +80,8 @@ module Benchmark
79
80
  # Default statistical model
80
81
  @stats = :sd
81
82
  @confidence = 95
83
+
84
+ self.quiet = false
82
85
  end
83
86
 
84
87
  # Job configuration options, set +@warmup+ and +@time+.
@@ -92,7 +95,7 @@ module Benchmark
92
95
  @iterations = opts[:iterations] if opts[:iterations]
93
96
  @stats = opts[:stats] if opts[:stats]
94
97
  @confidence = opts[:confidence] if opts[:confidence]
95
- self.quiet = opts[:quiet]
98
+ self.quiet = opts[:quiet] if opts.key?(:quiet)
96
99
  self.suite = opts[:suite]
97
100
  end
98
101
 
@@ -115,8 +118,9 @@ module Benchmark
115
118
  end
116
119
 
117
120
  # Run comparison utility.
118
- def compare!
121
+ def compare!(order: :fastest)
119
122
  @compare = true
123
+ @compare_order = order
120
124
  end
121
125
 
122
126
  # Return true if results are held while multiple Ruby invocations
@@ -274,9 +278,7 @@ module Benchmark
274
278
  target = Timing.add_second before, @warmup / 2.0
275
279
 
276
280
  cycles = 1
277
- warmup_iter = 1
278
- warmup_time_us = 0.0
279
- while Timing.now + warmup_time_us * 2 < target
281
+ begin
280
282
  t0 = Timing.now
281
283
  item.call_times cycles
282
284
  t1 = Timing.now
@@ -287,7 +289,7 @@ module Benchmark
287
289
  # then exit the loop to avoid overflows and start the 100ms warmup runs
288
290
  break if cycles >= POW_2_30
289
291
  cycles *= 2
290
- end
292
+ end while Timing.now + warmup_time_us * 2 < target
291
293
 
292
294
  cycles = cycles_per_100ms warmup_time_us, warmup_iter
293
295
  @timing[item] = cycles
@@ -324,7 +326,8 @@ module Benchmark
324
326
 
325
327
  target = Timing.add_second Timing.now, @time
326
328
 
327
- while (before = Timing.now) < target
329
+ begin
330
+ before = Timing.now
328
331
  item.call_times cycles
329
332
  after = Timing.now
330
333
 
@@ -336,7 +339,7 @@ module Benchmark
336
339
  iter += cycles
337
340
 
338
341
  measurements_us << iter_us
339
- end
342
+ end while Timing.now < target
340
343
 
341
344
  final_time = before
342
345
 
@@ -372,7 +375,7 @@ module Benchmark
372
375
 
373
376
  # Run comparison of entries in +@full_report+.
374
377
  def run_comparison
375
- @full_report.run_comparison if compare?
378
+ @full_report.run_comparison(@compare_order) if compare?
376
379
  end
377
380
 
378
381
  # Generate json from +@full_report+.
@@ -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
@@ -176,8 +176,8 @@ module Benchmark
176
176
  end
177
177
 
178
178
  # Run comparison of entries.
179
- def run_comparison
180
- Benchmark.compare(*@entries)
179
+ def run_comparison(order)
180
+ Benchmark.compare(*@entries, order: order)
181
181
  end
182
182
 
183
183
  # Generate json from Report#data to given path.
File without changes
@@ -33,6 +33,10 @@ module Benchmark
33
33
  [slowdown, error]
34
34
  end
35
35
 
36
+ def speedup(baseline)
37
+ baseline.slowdown(self)
38
+ end
39
+
36
40
  def footer
37
41
  "with #{(@confidence.to_f * 100).round(1)}% confidence"
38
42
  end
@@ -30,6 +30,10 @@ module Benchmark
30
30
  end
31
31
  end
32
32
 
33
+ def speedup(baseline)
34
+ baseline.slowdown(self)
35
+ end
36
+
33
37
  def footer
34
38
  nil
35
39
  end
File without changes
data/lib/benchmark/ips.rb CHANGED
@@ -18,10 +18,10 @@ module Benchmark
18
18
  module IPS
19
19
 
20
20
  # Benchmark-ips Gem version.
21
- VERSION = "2.9.0"
21
+ VERSION = "2.10.0"
22
22
 
23
23
  # CODENAME of current version.
24
- CODENAME = "Sleepy Sasquatch"
24
+ CODENAME = "Watashi Wa Genki"
25
25
 
26
26
  # Measure code in block, each code's benchmarked result will display in
27
27
  # iteration per second with standard deviation in given time.
File without changes
metadata CHANGED
@@ -1,95 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark-ips
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: minitest
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: '5.14'
19
- name: minitest
20
- prerelease: false
19
+ version: '5.4'
21
20
  type: :development
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.14'
26
+ version: '5.4'
27
27
  - !ruby/object:Gem::Dependency
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '4.0'
33
- - - "<"
34
- - !ruby/object:Gem::Version
35
- version: '7'
36
28
  name: rdoc
37
- prerelease: false
38
- type: :development
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '4.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '7'
47
- - !ruby/object:Gem::Dependency
48
29
  requirement: !ruby/object:Gem::Requirement
49
30
  requirements:
50
31
  - - "~>"
51
32
  - !ruby/object:Gem::Version
52
- version: '3.22'
53
- name: hoe
54
- prerelease: false
33
+ version: '4.0'
55
34
  type: :development
35
+ prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
38
  - - "~>"
59
39
  - !ruby/object:Gem::Version
60
- version: '3.22'
61
- description: An iterations per second enhancement to Benchmark.
40
+ version: '4.0'
41
+ description: A iterations per second enhancement to Benchmark.
62
42
  email:
63
43
  - evan@phx.io
64
44
  executables: []
65
45
  extensions: []
66
46
  extra_rdoc_files:
67
- - History.txt
68
- - Manifest.txt
47
+ - History.md
48
+ - LICENSE
69
49
  - README.md
70
50
  files:
71
- - ".autotest"
72
- - History.txt
73
- - Manifest.txt
51
+ - History.md
52
+ - LICENSE
74
53
  - README.md
75
- - Rakefile
54
+ - examples/advanced.rb
55
+ - examples/hold.rb
56
+ - examples/save.rb
57
+ - examples/simple.rb
76
58
  - lib/benchmark/compare.rb
77
59
  - lib/benchmark/ips.rb
78
60
  - lib/benchmark/ips/job.rb
79
61
  - lib/benchmark/ips/job/entry.rb
62
+ - lib/benchmark/ips/job/noop_report.rb
80
63
  - lib/benchmark/ips/job/stdout_report.rb
64
+ - lib/benchmark/ips/noop_suite.rb
81
65
  - lib/benchmark/ips/report.rb
82
66
  - lib/benchmark/ips/share.rb
83
67
  - lib/benchmark/ips/stats/bootstrap.rb
84
68
  - lib/benchmark/ips/stats/sd.rb
85
69
  - lib/benchmark/ips/stats/stats_metric.rb
86
70
  - lib/benchmark/timing.rb
87
- - test/test_benchmark_ips.rb
88
71
  homepage: https://github.com/evanphx/benchmark-ips
89
72
  licenses:
90
73
  - MIT
91
- metadata:
92
- homepage_uri: https://github.com/evanphx/benchmark-ips
74
+ metadata: {}
93
75
  post_install_message:
94
76
  rdoc_options:
95
77
  - "--main"
@@ -107,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
89
  - !ruby/object:Gem::Version
108
90
  version: '0'
109
91
  requirements: []
110
- rubygems_version: 3.1.6
92
+ rubygems_version: 3.2.26
111
93
  signing_key:
112
94
  specification_version: 4
113
- summary: An iterations per second enhancement to Benchmark.
95
+ summary: A iterations per second enhancement to Benchmark.
114
96
  test_files: []
data/.autotest DELETED
@@ -1,23 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'autotest/restart'
4
-
5
- # Autotest.add_hook :initialize do |at|
6
- # at.extra_files << "../some/external/dependency.rb"
7
- #
8
- # at.libs << ":../some/external"
9
- #
10
- # at.add_exception 'vendor'
11
- #
12
- # at.add_mapping(/dependency.rb/) do |f, _|
13
- # at.files_matching(/test_.*rb$/)
14
- # end
15
- #
16
- # %w(TestA TestB).each do |klass|
17
- # at.extra_class_map[klass] = "test/test_misc.rb"
18
- # end
19
- # end
20
-
21
- # Autotest.add_hook :run_command do |at|
22
- # system "rake build"
23
- # end
data/Manifest.txt DELETED
@@ -1,17 +0,0 @@
1
- .autotest
2
- History.txt
3
- Manifest.txt
4
- README.md
5
- Rakefile
6
- lib/benchmark/compare.rb
7
- lib/benchmark/ips.rb
8
- lib/benchmark/ips/job.rb
9
- lib/benchmark/ips/job/entry.rb
10
- lib/benchmark/ips/job/stdout_report.rb
11
- lib/benchmark/ips/report.rb
12
- lib/benchmark/ips/share.rb
13
- lib/benchmark/ips/stats/bootstrap.rb
14
- lib/benchmark/ips/stats/sd.rb
15
- lib/benchmark/ips/stats/stats_metric.rb
16
- lib/benchmark/timing.rb
17
- test/test_benchmark_ips.rb
data/Rakefile DELETED
@@ -1,27 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.plugin :minitest
7
- Hoe.plugin :git
8
- Hoe.plugin :ignore
9
-
10
- hoe = Hoe.spec 'benchmark-ips' do
11
- developer('Evan Phoenix', 'evan@phx.io')
12
-
13
- self.readme_file = 'README.md'
14
-
15
- license "MIT"
16
- end
17
-
18
- file "#{hoe.spec.name}.gemspec" => ['Rakefile', "lib/benchmark/ips.rb"] do |t|
19
- puts "Generating #{t.name}"
20
- File.open(t.name, 'wb') { |f| f.write hoe.spec.to_ruby }
21
- end
22
-
23
- desc "Generate or update the standalone gemspec file for the project"
24
- task :gemspec => ["#{hoe.spec.name}.gemspec"]
25
-
26
-
27
- # vim: syntax=ruby
@@ -1,221 +0,0 @@
1
- require "minitest/autorun"
2
- require "benchmark/ips"
3
- require "stringio"
4
- require "tmpdir"
5
-
6
- class TestBenchmarkIPS < Minitest::Test
7
- def setup
8
- @old_stdout = $stdout
9
- $stdout = StringIO.new
10
- end
11
-
12
- def teardown
13
- $stdout = @old_stdout
14
- end
15
-
16
- def test_kwargs
17
- Benchmark.ips(:time => 1, :warmup => 1, :quiet => false) do |x|
18
- x.report("sleep 0.25") { sleep(0.25) }
19
- end
20
-
21
- assert $stdout.string.size > 0
22
- end
23
-
24
- def test_warmup0
25
- $stdout = @old_stdout
26
-
27
- out, err = capture_io do
28
- Benchmark.ips(:time => 1, :warmup => 0, :quiet => false) do |x|
29
- x.report("sleep 0.25") { sleep(0.25) }
30
- end
31
- end
32
-
33
- refute_match(/Warming up -+/, out)
34
- assert_empty err
35
- end
36
-
37
- def test_output
38
- Benchmark.ips(1) do |x|
39
- x.report("operation") { 100 * 100 }
40
- end
41
-
42
- assert $stdout.string.size > 0
43
- end
44
-
45
- def test_quiet
46
- Benchmark.ips(1, nil, true) do |x|
47
- x.report("operation") { 100 * 100 }
48
- end
49
-
50
- assert $stdout.string.size.zero?
51
-
52
- Benchmark.ips(:quiet => true) do |x|
53
- x.report("operation") { 100 * 100 }
54
- end
55
-
56
- assert $stdout.string.size.zero?
57
-
58
- Benchmark.ips do |x|
59
- x.quiet = true
60
- x.report("operation") { 100 * 100 }
61
- end
62
-
63
- assert $stdout.string.size.zero?
64
- end
65
-
66
- def test_ips
67
- report = Benchmark.ips do |x|
68
- x.config(:time => 1, :warmup => 1)
69
- x.report("sleep 0.25") { sleep(0.25) }
70
- x.report("sleep 0.05") { sleep(0.05) }
71
- x.compare!
72
- end
73
-
74
- rep1 = report.entries[0]
75
- rep2 = report.entries[1]
76
-
77
- assert_equal "sleep 0.25", rep1.label
78
- assert_equal 4, rep1.iterations
79
- assert_in_delta 4.0, rep1.ips, 0.2
80
-
81
- assert_equal "sleep 0.05", rep2.label
82
- assert_in_delta 20.0, rep2.iterations.to_f, 1.0
83
- assert_in_delta 20.0, rep2.ips, 2.0
84
- end
85
-
86
- def test_ips_alternate_config
87
- report = Benchmark.ips do |x|
88
- x.time = 1
89
- x.warmup = 1
90
- x.report("sleep 0.25") { sleep(0.25) }
91
- end
92
-
93
- rep = report.entries.first
94
-
95
- assert_equal "sleep 0.25", rep.label
96
- assert_equal 4, rep.iterations
97
- assert_in_delta 4.0, rep.ips, 0.4
98
- end
99
-
100
- def test_ips_old_config
101
- report = Benchmark.ips(1,1) do |x|
102
- x.report("sleep 0.25") { sleep(0.25) }
103
- end
104
-
105
- rep = report.entries.first
106
-
107
- assert_equal "sleep 0.25", rep.label
108
- assert_equal 4, rep.iterations
109
- assert_in_delta 4.0, rep.ips, 0.2
110
- end
111
-
112
- def test_ips_config_suite
113
- suite = Struct.new(:calls) do
114
- def method_missing(method, *args)
115
- calls << method
116
- end
117
- end.new([])
118
-
119
- Benchmark.ips(0.1, 0.1) do |x|
120
- x.config(:suite => suite)
121
- x.report("job") {}
122
- end
123
-
124
- assert_equal [:warming, :warmup_stats, :running, :add_report], suite.calls
125
- end
126
-
127
- def test_ips_config_suite_by_accsr
128
- suite = Struct.new(:calls) do
129
- def method_missing(method, *args)
130
- calls << method
131
- end
132
- end.new([])
133
-
134
- Benchmark.ips(0.1, 0.1) do |x|
135
- x.suite = suite
136
- x.report("job") {}
137
- end
138
-
139
- assert_equal [:warming, :warmup_stats, :running, :add_report], suite.calls
140
- end
141
-
142
- def test_ips_defaults
143
- report = Benchmark.ips do |x|
144
- x.report("sleep 0.25") { sleep(0.25) }
145
- end
146
-
147
- rep = report.entries.first
148
-
149
- assert_equal "sleep 0.25", rep.label
150
- assert_equal 4*5, rep.iterations
151
- assert_in_delta 4.0, rep.ips, 0.2
152
- end
153
-
154
- def test_ips_report_using_symbol
155
- report = Benchmark.ips do |x|
156
- x.report(:sleep_a_quarter_second) { sleep(0.25) }
157
- end
158
-
159
- rep = report.entries.first
160
-
161
- assert_equal :sleep_a_quarter_second, rep.label
162
- assert_equal 4*5, rep.iterations
163
- assert_in_delta 4.0, rep.ips, 0.2
164
- end
165
-
166
- def test_ips_default_data
167
- report = Benchmark.ips do |x|
168
- x.report("sleep 0.25") { sleep(0.25) }
169
- end
170
-
171
- all_data = report.data
172
-
173
- assert all_data
174
- assert_equal "sleep 0.25", all_data[0][:name]
175
- assert all_data[0][:ips]
176
- assert all_data[0][:stddev]
177
- end
178
-
179
- def test_ips_empty
180
- report = Benchmark.ips do |_x|
181
-
182
- end
183
-
184
- all_data = report.data
185
-
186
- assert all_data
187
- assert_equal [], all_data
188
- end
189
-
190
- def test_json_output
191
- json_file = Tempfile.new("data.json")
192
-
193
- Benchmark.ips do |x|
194
- x.report("sleep 0.25") { sleep(0.25) }
195
- x.json! json_file.path
196
- end
197
-
198
- json_data = json_file.read
199
- assert json_data
200
-
201
- data = JSON.parse json_data
202
- assert data
203
- assert_equal 1, data.size
204
- assert_equal "sleep 0.25", data[0]["name"]
205
- assert data[0]["ips"]
206
- assert data[0]["stddev"]
207
- end
208
-
209
- def test_hold!
210
- temp_file_name = Dir::Tmpname.create(["benchmark-ips", ".tmp"]) { }
211
-
212
- Benchmark.ips(:time => 0.001, :warmup => 0.001) do |x|
213
- x.report("operation") { 100 * 100 }
214
- x.report("operation2") { 100 * 100 }
215
- x.hold! temp_file_name
216
- end
217
-
218
- assert File.exist?(temp_file_name)
219
- File.unlink(temp_file_name)
220
- end
221
- end