benchmark-ips 2.8.0 → 2.8.2

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: 54899cb6088746f3b585d3e471795fa63c5fa06b9a452e7923d5211ea096eff1
4
- data.tar.gz: 21f3a97a2971d77dbf33fa05a497f7c61499497da66b8aff26987c64d6e2de3c
3
+ metadata.gz: da5b50c171ff2a6a40819f6b8d9558052555b93661c4b5f9d7b381dcafaf3e97
4
+ data.tar.gz: 68bb278b667a4c508a3dfc6474f78ced7f9b211495c51e4c3e020b6b24dc21b8
5
5
  SHA512:
6
- metadata.gz: 3b7dd9271181dc58b32864d0d60ecf58c8daf92dc024ab764bc07289a39650db30354d72fc8f586207c6f5ccfaccf72c41eb9ac75d4e7be7af7a18c60f6e7860
7
- data.tar.gz: 11731f19a4fbc1abcc6e31ad6c5d4ea752f26d3a5ce9573b4e07011b568c455abfbd5a53b5e41408d7e931a5327d1c6c0a2200c25d10897b9d4111d45326c7d5
6
+ metadata.gz: 96a2659f8cac1f286fb4074a7a6c590e64e32b8085b1190047dc4b9a4ad6e218846701672459347d984b46b00b49d74ddaeaba284c01204e6f6d41010f1d8677
7
+ data.tar.gz: 909b29dd0874432f9a08df7f4728029b1bfda0b3499d11a74a04c946beaa82f296ef552aee4e104c7149f1456dc2481186eef166ad10398f5ad36a340cb32c81
@@ -12,5 +12,6 @@ lib/benchmark/ips/report.rb
12
12
  lib/benchmark/ips/share.rb
13
13
  lib/benchmark/ips/stats/bootstrap.rb
14
14
  lib/benchmark/ips/stats/sd.rb
15
+ lib/benchmark/ips/stats/stats_metric.rb
15
16
  lib/benchmark/timing.rb
16
17
  test/test_benchmark_ips.rb
@@ -16,7 +16,7 @@ module Benchmark
16
16
  module IPS
17
17
 
18
18
  # Benchmark-ips Gem version.
19
- VERSION = "2.8.0"
19
+ VERSION = "2.8.2"
20
20
 
21
21
  # CODENAME of current version.
22
22
  CODENAME = "Tardy Turtle"
@@ -109,6 +109,8 @@ module Benchmark
109
109
  end
110
110
  end
111
111
 
112
+ extend Benchmark::IPS # make ips available as module-level method
113
+
112
114
  ##
113
115
  # :singleton-method: ips
114
116
  #
@@ -172,5 +174,4 @@ module Benchmark
172
174
  # addition: 4955278.9 i/s - 4.85x slower
173
175
  #
174
176
  # See also Benchmark::IPS
175
- extend Benchmark::IPS # make ips available as module-level method
176
177
  end
@@ -187,7 +187,7 @@ module Benchmark
187
187
  end
188
188
 
189
189
  def load_held_results
190
- return unless @held_path && File.exist?(@held_path)
190
+ return unless @held_path && !File.zero?(@held_path)
191
191
  require "json"
192
192
  @held_results = {}
193
193
  JSON.load(IO.read(@held_path)).each do |result|
@@ -11,10 +11,12 @@ module Benchmark
11
11
  def initialize(label, action)
12
12
  @label = label
13
13
 
14
+ # We define #call_times on the singleton class of each Entry instance.
15
+ # That way, there is no polymorphism for `@action.call` inside #call_times.
16
+
14
17
  if action.kind_of? String
15
- compile action
18
+ compile_string action
16
19
  @action = self
17
- @as_action = true
18
20
  else
19
21
  unless action.respond_to? :call
20
22
  raise ArgumentError, "invalid action, must respond to #call"
@@ -23,12 +25,10 @@ module Benchmark
23
25
  @action = action
24
26
 
25
27
  if action.respond_to? :arity and action.arity > 0
26
- @call_loop = true
28
+ compile_block_with_manual_loop
27
29
  else
28
- @call_loop = false
30
+ compile_block
29
31
  end
30
-
31
- @as_action = false
32
32
  end
33
33
  end
34
34
 
@@ -40,25 +40,43 @@ module Benchmark
40
40
  # @return [String, Proc] Code to be called, could be String / Proc.
41
41
  attr_reader :action
42
42
 
43
- # Call action by given times, return if +@call_loop+ is present.
43
+ # Call action by given times.
44
44
  # @param times [Integer] Times to call +@action+.
45
45
  # @return [Integer] Number of times the +@action+ has been called.
46
46
  def call_times(times)
47
- return @action.call(times) if @call_loop
47
+ raise '#call_times should be redefined per Benchmark::IPS::Job::Entry instance'
48
+ end
48
49
 
49
- act = @action
50
+ def compile_block
51
+ m = (class << self; self; end)
52
+ code = <<-CODE
53
+ def call_times(times)
54
+ act = @action
50
55
 
51
- i = 0
52
- while i < times
53
- act.call
54
- i += 1
55
- end
56
+ i = 0
57
+ while i < times
58
+ act.call
59
+ i += 1
60
+ end
61
+ end
62
+ CODE
63
+ m.class_eval code
64
+ end
65
+
66
+ def compile_block_with_manual_loop
67
+ m = (class << self; self; end)
68
+ code = <<-CODE
69
+ def call_times(times)
70
+ @action.call(times)
71
+ end
72
+ CODE
73
+ m.class_eval code
56
74
  end
57
75
 
58
76
  # Compile code into +call_times+ method.
59
77
  # @param str [String] Code to be compiled.
60
78
  # @return [Symbol] :call_times.
61
- def compile(str)
79
+ def compile_string(str)
62
80
  m = (class << self; self; end)
63
81
  code = <<-CODE
64
82
  def call_times(__total);
@@ -0,0 +1,21 @@
1
+ module Benchmark
2
+ module IPS
3
+ module Stats
4
+ module StatsMetric
5
+ # Return entry's standard deviation of iteration per second in percentage.
6
+ # @return [Float] +@ips_sd+ in percentage.
7
+ def error_percentage
8
+ 100.0 * (error.to_f / central_tendency)
9
+ end
10
+
11
+ def overlaps?(baseline)
12
+ baseline_low = baseline.central_tendency - baseline.error
13
+ baseline_high = baseline.central_tendency + baseline.error
14
+ my_high = central_tendency + error
15
+ my_low = central_tendency - error
16
+ my_high > baseline_low && my_low < baseline_high
17
+ end
18
+ end
19
+ end
20
+ end
21
+ 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.8.0
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -82,6 +82,7 @@ files:
82
82
  - lib/benchmark/ips/share.rb
83
83
  - lib/benchmark/ips/stats/bootstrap.rb
84
84
  - lib/benchmark/ips/stats/sd.rb
85
+ - lib/benchmark/ips/stats/stats_metric.rb
85
86
  - lib/benchmark/timing.rb
86
87
  - test/test_benchmark_ips.rb
87
88
  homepage: https://github.com/evanphx/benchmark-ips
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  - !ruby/object:Gem::Version
107
108
  version: '0'
108
109
  requirements: []
109
- rubygems_version: 3.0.3
110
+ rubygems_version: 3.1.2
110
111
  signing_key:
111
112
  specification_version: 4
112
113
  summary: An iterations per second enhancement to Benchmark.