benchmark-ips 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. data/lib/benchmark/ips.rb +30 -7
  2. metadata +3 -3
@@ -5,7 +5,7 @@ require 'benchmark/compare'
5
5
  module Benchmark
6
6
 
7
7
  class IPSReport
8
- VERSION = "1.0.0"
8
+ VERSION = "1.1.0"
9
9
 
10
10
  def initialize(label, us, iters, ips, ips_sd, cycles)
11
11
  @label = label
@@ -30,8 +30,7 @@ module Benchmark
30
30
 
31
31
  def body
32
32
  left = "%10.1f (±%.1f%%) i/s" % [ips, stddev_percentage]
33
- left.ljust(20) + (" - %10d in %10.6fs (cycle=%d)" %
34
- [@iterations, runtime, @measurement_cycle])
33
+ left.ljust(20) + (" - %10d in %10.6fs" % [@iterations, runtime])
35
34
  end
36
35
 
37
36
  def header
@@ -147,17 +146,23 @@ module Benchmark
147
146
  suite = Benchmark::Suite.current
148
147
  end
149
148
 
149
+ quiet = suite && !suite.quiet?
150
+
150
151
  job = IPSJob.new
151
152
  yield job
152
153
 
153
154
  reports = []
154
155
 
156
+ timing = {}
157
+
158
+ $stdout.puts "Calculating -------------------------------------" unless quiet
159
+
155
160
  job.list.each do |item|
156
161
  suite.warming item.label, warmup if suite
157
162
 
158
163
  Timing.clean_env
159
164
 
160
- if !suite or !suite.quiet?
165
+ unless quiet
161
166
  if item.label.size > 20
162
167
  $stdout.print "#{item.label}\n#{' ' * 20}"
163
168
  else
@@ -184,7 +189,23 @@ module Benchmark
184
189
  cycles_per_100ms = ((100_000 / warmup_time) * warmup_iter).to_i
185
190
  cycles_per_100ms = 1 if cycles_per_100ms <= 0
186
191
 
192
+ timing[item] = cycles_per_100ms
193
+
194
+ $stdout.printf "%10d i/100ms\n", cycles_per_100ms unless quiet
195
+
187
196
  suite.warmup_stats warmup_time, cycles_per_100ms if suite
197
+ end
198
+
199
+ $stdout.puts "-------------------------------------------------" unless quiet
200
+
201
+ job.list.each do |item|
202
+ unless quiet
203
+ if item.label.size > 20
204
+ $stdout.print "#{item.label}\n#{' ' * 20}"
205
+ else
206
+ $stdout.print item.label.rjust(20)
207
+ end
208
+ end
188
209
 
189
210
  Timing.clean_env
190
211
 
@@ -196,6 +217,8 @@ module Benchmark
196
217
 
197
218
  measurements = []
198
219
 
220
+ cycles_per_100ms = timing[item]
221
+
199
222
  while Time.now < target
200
223
  before = Time.now
201
224
  item.call_times cycles_per_100ms
@@ -217,15 +240,15 @@ module Benchmark
217
240
 
218
241
  rep = IPSReport.new(item.label, measured_us, iter, avg_ips, sd_ips, cycles_per_100ms)
219
242
 
220
- $stdout.puts " #{rep.body}" if !suite or !suite.quiet?
243
+ $stdout.puts " #{rep.body}" unless quiet
221
244
 
222
245
  suite.add_report rep, caller(1).first if suite
223
246
 
224
- $stdout.sync = sync
225
-
226
247
  reports << rep
227
248
  end
228
249
 
250
+ $stdout.sync = sync
251
+
229
252
  if job.compare
230
253
  Benchmark.compare(*reports)
231
254
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark-ips
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Phoenix