benchmark-ips 2.4.1 → 2.5.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
  SHA1:
3
- metadata.gz: 9b51b0526730c2f62df99ab99a7b9ee4455bd551
4
- data.tar.gz: e831277bf0718b4451f172a5f379d9cefc6c7efe
3
+ metadata.gz: 800887a127821360c847dbd86fc49f386d388635
4
+ data.tar.gz: e0704aeb51a6f7d4983efc77b564a0989eb93502
5
5
  SHA512:
6
- metadata.gz: 911bcd01427c54ac09b86ba506fe5c59b79eb0f8bff27ac58b79bfdd084de80aa91d0cec6fda0df9c591d55185ed4c922006039d6b74f597fcfb99045ce80a59
7
- data.tar.gz: 7453a913d40e0c6751dbc5e69bdfa2cb749c387568ebaebaed9b401bf65c1adc8aa4aa56a7c9ba31f60e0e1ff27cc9473b3c961f6cc2e9538ad5be64e209b583
6
+ metadata.gz: cc0b35e7b9734ca9b5bdae5c8c74f5c06106d208e6d9aa85985b144e127354e81f0fe368492fabdd64df7dfb510339a30540fe745c9584c7bb1924d8f97a12e3
7
+ data.tar.gz: 10da5a56f4f9b1ba049d21823dfe1b737f54fc0667cd484cead92e2e22f8ae2fb38c58f353d23592523173096731a30f81129aed8d34904dd474594d411fb26a
@@ -1,3 +1,15 @@
1
+ === 2.5.0 / 2016-02-14
2
+
3
+ * 1 minor feature:
4
+ * Add iterations option.
5
+
6
+ * 1 bug fixes:
7
+ * Don't tell people something is slower if it's within the error.
8
+
9
+ * 2 merged PRs:
10
+ * Merge pull request #58 from chrisseaton/iterations
11
+ * Merge pull request #60 from chrisseaton/significance
12
+
1
13
  === 2.4.1 / 2016-02-12
2
14
 
3
15
  * 1 bug fix:
data/README.md CHANGED
@@ -145,8 +145,6 @@ are independent of each other. You can do this with the `hold!` command.
145
145
  ```ruby
146
146
  Benchmark.ips do |x|
147
147
 
148
- ...
149
-
150
148
  # Hold results between multiple invocations of Ruby
151
149
  x.hold! 'filename'
152
150
 
@@ -157,6 +155,29 @@ This will run only one benchmarks each time you run the command, storing
157
155
  results in the specified file. The file is deleted when all results have been
158
156
  gathered and the report is shown.
159
157
 
158
+ ### Multiple iterations
159
+
160
+ In some cases you may want to run multiple iterations of the warmup and
161
+ calculation stages and take only the last result for comparison. This is useful
162
+ if you are benchmarking with an implementation of Ruby that optimizes using
163
+ tracing or on-stack-replacement, because to those implementations the
164
+ calculation phase may appear as new, unoptimized code.
165
+
166
+ You can do this with the `iterations` option, which by default is `1`. The
167
+ total time spent will then be `iterations * warmup + iterations * time` seconds.
168
+
169
+ ```ruby
170
+ Benchmark.ips do |x|
171
+
172
+ x.config(:iterations => 3)
173
+
174
+ # or
175
+
176
+ x.iterations = 3
177
+
178
+ end
179
+ ```
180
+
160
181
  ## REQUIREMENTS:
161
182
 
162
183
  * None!
@@ -42,9 +42,21 @@ module Benchmark
42
42
 
43
43
  sorted.each do |report|
44
44
  name = report.label.to_s
45
-
46
- x = (best.ips.to_f / report.ips.to_f)
47
- $stdout.printf "%20s: %10.1f i/s - %.2fx slower\n", name, report.ips, x
45
+
46
+ $stdout.printf "%20s: %10.1f i/s - ", name, report.ips
47
+
48
+ best_low = best.ips - best.ips_sd
49
+ report_high = report.ips + report.ips_sd
50
+ overlaps = report_high > best_low
51
+
52
+ if overlaps
53
+ $stdout.print "same-ish: difference falls within error"
54
+ else
55
+ x = (best.ips.to_f / report.ips.to_f)
56
+ $stdout.printf "%.2fx slower", x
57
+ end
58
+
59
+ $stdout.puts
48
60
  end
49
61
 
50
62
  $stdout.puts
@@ -13,10 +13,10 @@ module Benchmark
13
13
  module IPS
14
14
 
15
15
  # Benchmark-ips Gem version.
16
- VERSION = "2.4.1"
16
+ VERSION = "2.5.0"
17
17
 
18
18
  # CODENAME of current version.
19
- CODENAME = "Nonlinear Rollercoaster"
19
+ CODENAME = "Oceanload"
20
20
 
21
21
  # Measure code in block, each code's benchmarked result will display in
22
22
  # iteration per second with standard deviation in given time.
@@ -54,7 +54,6 @@ module Benchmark
54
54
 
55
55
  job.load_held_results if job.hold? && job.held_results?
56
56
 
57
- job.run_warmup
58
57
  job.run
59
58
 
60
59
  $stdout.sync = sync
@@ -38,6 +38,10 @@ module Benchmark
38
38
  # @return [Integer]
39
39
  attr_accessor :time
40
40
 
41
+ # Warmup and calculation iterations.
42
+ # @return [Integer]
43
+ attr_accessor :iterations
44
+
41
45
  # Instantiate the Benchmark::IPS::Job.
42
46
  # @option opts [Benchmark::Suite] (nil) :suite Specify Benchmark::Suite.
43
47
  # @option opts [Boolean] (false) :quiet Suppress the printing of information.
@@ -56,15 +60,18 @@ module Benchmark
56
60
  # Default warmup and calculation time in seconds.
57
61
  @warmup = 2
58
62
  @time = 5
63
+ @iterations = 1
59
64
  end
60
65
 
61
66
  # Job configuration options, set +@warmup+ and +@time+.
62
67
  # @option opts [Integer] :warmup Warmup time.
63
68
  # @option opts [Integer] :time Calculation time.
69
+ # @option iterations [Integer] :time Warmup and calculation iterations.
64
70
  def config opts
65
71
  @warmup = opts[:warmup] if opts[:warmup]
66
72
  @time = opts[:time] if opts[:time]
67
73
  @suite = opts[:suite] if opts[:suite]
74
+ @iterations = opts[:iterations] if opts[:iterations]
68
75
  end
69
76
 
70
77
  # Return true if job needs to be compared.
@@ -158,10 +165,29 @@ module Benchmark
158
165
  [result['item'], result]
159
166
  }]
160
167
  end
168
+
169
+ def run
170
+ @stdout.start_warming if @stdout
171
+ @iterations.times do
172
+ run_warmup
173
+ end
174
+
175
+ @stdout.start_running if @stdout
176
+
177
+ held = nil
178
+
179
+ @iterations.times do |n|
180
+ held = run_benchmark
181
+ end
182
+
183
+ if held
184
+ puts
185
+ puts 'Pausing here -- run Ruby again to measure the next benchmark...'
186
+ end
187
+ end
161
188
 
162
189
  # Run warmup.
163
190
  def run_warmup
164
- @stdout.start_warming if @stdout
165
191
  @list.each do |item|
166
192
  next if hold? && @held_results && @held_results.key?(item.label)
167
193
 
@@ -194,8 +220,7 @@ module Benchmark
194
220
  end
195
221
 
196
222
  # Run calculation.
197
- def run
198
- @stdout.start_running if @stdout
223
+ def run_benchmark
199
224
  @list.each do |item|
200
225
  if hold? && @held_results && @held_results.key?(item.label)
201
226
  result = @held_results[item.label]
@@ -267,15 +292,15 @@ module Benchmark
267
292
  f.write "\n"
268
293
  end
269
294
 
270
- puts
271
- puts 'Pausing here -- run Ruby again to measure the next benchmark...'
272
- break
295
+ return true
273
296
  end
274
297
  end
275
298
 
276
299
  if hold? && @full_report.entries.size == @list.size
277
300
  File.delete @held_path if File.exist?(@held_path)
278
301
  end
302
+
303
+ false
279
304
  end
280
305
 
281
306
  # Run comparison of entries in +@full_report+.
@@ -137,6 +137,7 @@ module Benchmark
137
137
  # @return [Report::Entry] Last added entry.
138
138
  def add_entry label, microseconds, iters, ips, ips_sd, measurement_cycle
139
139
  entry = Entry.new(label, microseconds, iters, ips, ips_sd, measurement_cycle)
140
+ @entries.delete_if { |e| e.label == label }
140
141
  @entries << entry
141
142
  entry
142
143
  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.1
4
+ version: 2.5.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: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest