benchmark-ips 2.5.0 → 2.6.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: 800887a127821360c847dbd86fc49f386d388635
4
- data.tar.gz: e0704aeb51a6f7d4983efc77b564a0989eb93502
3
+ metadata.gz: 35df2320273ed4690c943dbbda6acf1e005c8c99
4
+ data.tar.gz: f41d28b189e3a1968943385cda9c67e47ff0f459
5
5
  SHA512:
6
- metadata.gz: cc0b35e7b9734ca9b5bdae5c8c74f5c06106d208e6d9aa85985b144e127354e81f0fe368492fabdd64df7dfb510339a30540fe745c9584c7bb1924d8f97a12e3
7
- data.tar.gz: 10da5a56f4f9b1ba049d21823dfe1b737f54fc0667cd484cead92e2e22f8ae2fb38c58f353d23592523173096731a30f81129aed8d34904dd474594d411fb26a
6
+ metadata.gz: ddbf666d2506af90fdb6d9fdc68dfd3b82935e91faffa88e1d569fcba14893d5451ad8fc202a10dd1565f9b534635b2b40bb542507ae6145bb4520a8231ef538
7
+ data.tar.gz: 52f192abde81aff38251b6c5196e5115381cf76040b3ff04d64d2d029c0c230ef55e5926f1425dfed11dd99d2db6844517ebd647c597712f594679ec2ff40144
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## DESCRIPTION:
12
12
 
13
- A iterations per second enhancement to Benchmark.
13
+ An iterations per second enhancement to Benchmark.
14
14
 
15
15
  ## FEATURES/PROBLEMS:
16
16
 
@@ -13,10 +13,10 @@ module Benchmark
13
13
  module IPS
14
14
 
15
15
  # Benchmark-ips Gem version.
16
- VERSION = "2.5.0"
16
+ VERSION = "2.6.0"
17
17
 
18
18
  # CODENAME of current version.
19
- CODENAME = "Oceanload"
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.
@@ -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 = 1_000_000
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 = Time.now
200
- target = Time.now + @warmup
199
+ before = Timing.now
200
+ target = Timing.add_second before, @warmup
201
201
 
202
202
  warmup_iter = 0
203
203
 
204
- while Time.now < target
204
+ while Timing.now < target
205
205
  item.call_times(1)
206
206
  warmup_iter += 1
207
207
  end
208
208
 
209
- after = Time.now
209
+ after = Timing.now
210
210
 
211
- warmup_time_us = time_us before, after
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 = Time.now + @time
244
+ target = Timing.add_second Timing.now, @time
245
245
 
246
- while Time.now < target
247
- before = Time.now
246
+ while (before = Timing.now) < target
248
247
  item.call_times cycles
249
- after = Time.now
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 = Time.now
260
+ final_time = before
262
261
 
263
262
  measured_us = measurements_us.inject(0) { |a,i| a + i }
264
263
 
@@ -147,13 +147,19 @@ module Benchmark
147
147
  # name: Entry#label
148
148
  # ips: Entry#ips
149
149
  # stddev: Entry#ips_sd
150
- # @return [Array<Hash<Symbol,String|Float>] Array of hashes with :label, :ips, :stddev
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
@@ -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.5.0
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-02-15 00:00:00.000000000 Z
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.14'
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.14'
55
- description: A iterations per second enhancement to Benchmark.
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: A iterations per second enhancement to Benchmark.
103
+ summary: An iterations per second enhancement to Benchmark.
104
104
  test_files: []