benchmark-ips 2.5.0 → 2.6.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/README.md +1 -1
- data/lib/benchmark/ips.rb +12 -4
- data/lib/benchmark/ips/job.rb +11 -12
- data/lib/benchmark/ips/report.rb +8 -2
- data/lib/benchmark/timing.rb +37 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35df2320273ed4690c943dbbda6acf1e005c8c99
|
4
|
+
data.tar.gz: f41d28b189e3a1968943385cda9c67e47ff0f459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddbf666d2506af90fdb6d9fdc68dfd3b82935e91faffa88e1d569fcba14893d5451ad8fc202a10dd1565f9b534635b2b40bb542507ae6145bb4520a8231ef538
|
7
|
+
data.tar.gz: 52f192abde81aff38251b6c5196e5115381cf76040b3ff04d64d2d029c0c230ef55e5926f1425dfed11dd99d2db6844517ebd647c597712f594679ec2ff40144
|
data/README.md
CHANGED
data/lib/benchmark/ips.rb
CHANGED
@@ -13,10 +13,10 @@ module Benchmark
|
|
13
13
|
module IPS
|
14
14
|
|
15
15
|
# Benchmark-ips Gem version.
|
16
|
-
VERSION = "2.
|
16
|
+
VERSION = "2.6.0"
|
17
17
|
|
18
18
|
# CODENAME of current version.
|
19
|
-
CODENAME = "
|
19
|
+
CODENAME = "Sharing is Caring"
|
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.
|
@@ -51,7 +51,7 @@ module Benchmark
|
|
51
51
|
job.config job_opts
|
52
52
|
|
53
53
|
yield job
|
54
|
-
|
54
|
+
|
55
55
|
job.load_held_results if job.hold? && job.held_results?
|
56
56
|
|
57
57
|
job.run
|
@@ -60,7 +60,15 @@ module Benchmark
|
|
60
60
|
job.run_comparison
|
61
61
|
job.generate_json
|
62
62
|
|
63
|
-
job.full_report
|
63
|
+
report = job.full_report
|
64
|
+
|
65
|
+
if ENV['SHARE'] || ENV['SHARE_URL']
|
66
|
+
require 'benchmark/ips/share'
|
67
|
+
share = Share.new report, job
|
68
|
+
share.share
|
69
|
+
end
|
70
|
+
|
71
|
+
report
|
64
72
|
end
|
65
73
|
|
66
74
|
# Set options for running the benchmarks.
|
data/lib/benchmark/ips/job.rb
CHANGED
@@ -5,7 +5,7 @@ module Benchmark
|
|
5
5
|
# Microseconds per 100 millisecond.
|
6
6
|
MICROSECONDS_PER_100MS = 100_000
|
7
7
|
# Microseconds per second.
|
8
|
-
MICROSECONDS_PER_SECOND =
|
8
|
+
MICROSECONDS_PER_SECOND = Timing::MICROSECONDS_PER_SECOND
|
9
9
|
# The percentage of the expected runtime to allow
|
10
10
|
# before reporting a weird runtime
|
11
11
|
MAX_TIME_SKEW = 0.05
|
@@ -196,19 +196,19 @@ module Benchmark
|
|
196
196
|
|
197
197
|
Timing.clean_env
|
198
198
|
|
199
|
-
before =
|
200
|
-
target =
|
199
|
+
before = Timing.now
|
200
|
+
target = Timing.add_second before, @warmup
|
201
201
|
|
202
202
|
warmup_iter = 0
|
203
203
|
|
204
|
-
while
|
204
|
+
while Timing.now < target
|
205
205
|
item.call_times(1)
|
206
206
|
warmup_iter += 1
|
207
207
|
end
|
208
208
|
|
209
|
-
after =
|
209
|
+
after = Timing.now
|
210
210
|
|
211
|
-
warmup_time_us = time_us
|
211
|
+
warmup_time_us = Timing.time_us(before, after)
|
212
212
|
|
213
213
|
@timing[item] = cycles_per_100ms warmup_time_us, warmup_iter
|
214
214
|
|
@@ -241,16 +241,15 @@ module Benchmark
|
|
241
241
|
# Running this number of cycles should take around 100ms.
|
242
242
|
cycles = @timing[item]
|
243
243
|
|
244
|
-
target =
|
244
|
+
target = Timing.add_second Timing.now, @time
|
245
245
|
|
246
|
-
while
|
247
|
-
before = Time.now
|
246
|
+
while (before = Timing.now) < target
|
248
247
|
item.call_times cycles
|
249
|
-
after =
|
248
|
+
after = Timing.now
|
250
249
|
|
251
250
|
# If for some reason the timing said this took no time (O_o)
|
252
251
|
# then ignore the iteration entirely and start another.
|
253
|
-
iter_us = time_us before, after
|
252
|
+
iter_us = Timing.time_us before, after
|
254
253
|
next if iter_us <= 0.0
|
255
254
|
|
256
255
|
iter += cycles
|
@@ -258,7 +257,7 @@ module Benchmark
|
|
258
257
|
measurements_us << iter_us
|
259
258
|
end
|
260
259
|
|
261
|
-
final_time =
|
260
|
+
final_time = before
|
262
261
|
|
263
262
|
measured_us = measurements_us.inject(0) { |a,i| a + i }
|
264
263
|
|
data/lib/benchmark/ips/report.rb
CHANGED
@@ -147,13 +147,19 @@ module Benchmark
|
|
147
147
|
# name: Entry#label
|
148
148
|
# ips: Entry#ips
|
149
149
|
# stddev: Entry#ips_sd
|
150
|
-
#
|
150
|
+
# microseconds: Entry#microseconds
|
151
|
+
# iterations: Entry#iterations
|
152
|
+
# cycles: Entry#measurement_cycles
|
153
|
+
# @return [Array<Hash<Symbol,String|Float|Integer>] Array of hashes
|
151
154
|
def data
|
152
155
|
@data ||= @entries.collect do |entry|
|
153
156
|
{
|
154
157
|
:name => entry.label,
|
155
158
|
:ips => entry.ips,
|
156
|
-
:stddev => entry.ips_sd
|
159
|
+
:stddev => entry.ips_sd,
|
160
|
+
:microseconds => entry.microseconds,
|
161
|
+
:iterations => entry.iterations,
|
162
|
+
:cycles => entry.measurement_cycle,
|
157
163
|
}
|
158
164
|
end
|
159
165
|
end
|
data/lib/benchmark/timing.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Benchmark
|
2
2
|
# Perform caclulations on Timing results.
|
3
3
|
module Timing
|
4
|
+
# Microseconds per second.
|
5
|
+
MICROSECONDS_PER_SECOND = 1_000_000
|
4
6
|
|
5
7
|
# Calculate (arithmetic) mean of given samples.
|
6
8
|
# @param [Array] samples Samples to calculate mean.
|
@@ -52,5 +54,40 @@ module Benchmark
|
|
52
54
|
GC.start
|
53
55
|
end
|
54
56
|
end
|
57
|
+
|
58
|
+
# Use a monotonic clock if available, otherwise use Time
|
59
|
+
begin
|
60
|
+
Process.clock_gettime Process::CLOCK_MONOTONIC, :float_microsecond
|
61
|
+
|
62
|
+
# Get an object that represents now and can be converted to microseconds
|
63
|
+
def self.now
|
64
|
+
Process.clock_gettime Process::CLOCK_MONOTONIC, :float_microsecond
|
65
|
+
end
|
66
|
+
|
67
|
+
# Add one second to the time represenetation
|
68
|
+
def self.add_second(t, s)
|
69
|
+
return t + (s * MICROSECONDS_PER_SECOND)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Return the number of microseconds between the 2 moments
|
73
|
+
def self.time_us(before, after)
|
74
|
+
after - before
|
75
|
+
end
|
76
|
+
rescue NameError
|
77
|
+
# Get an object that represents now and can be converted to microseconds
|
78
|
+
def self.now
|
79
|
+
Time.now
|
80
|
+
end
|
81
|
+
|
82
|
+
# Add one second to the time represenetation
|
83
|
+
def self.add_second(t, s)
|
84
|
+
return t + s
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return the number of microseconds between the 2 moments
|
88
|
+
def self.time_us(before, after)
|
89
|
+
(after.to_f - before.to_f) * MICROSECONDS_PER_SECOND
|
90
|
+
end
|
91
|
+
end
|
55
92
|
end
|
56
93
|
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.6.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-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -44,15 +44,15 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.15'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
55
|
-
description:
|
54
|
+
version: '3.15'
|
55
|
+
description: An iterations per second enhancement to Benchmark.
|
56
56
|
email:
|
57
57
|
- evan@phx.io
|
58
58
|
executables: []
|
@@ -100,5 +100,5 @@ rubyforge_project:
|
|
100
100
|
rubygems_version: 2.5.1
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
|
-
summary:
|
103
|
+
summary: An iterations per second enhancement to Benchmark.
|
104
104
|
test_files: []
|