benchmark_driver 0.15.6 → 0.15.7

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: ee7ac11d17c4926fef5eee52f240b880c71c5d010ff6f80efbe912c54b9d1ce7
4
- data.tar.gz: ea0c62cf7b4f19f628c94e35e4544b11aec29ece0efb54bccf1fcd06579c90af
3
+ metadata.gz: ad73033408aa70dae54e87ff9fbcfee14ba00ecf22201113f3f09083c57e9781
4
+ data.tar.gz: d6bc8f3296d6cbc1565a3fd69e69ad6eda942a72d7b5d388f415b81911f11339
5
5
  SHA512:
6
- metadata.gz: 823b2d90606dd3f4093a0f92d3860fd61c04584f989fc0935b57f8dfa6d2ef4d33afcbf792e862f486ff9bf980ad63e4693663d5696a878ad4f3c5c2185e6d2c
7
- data.tar.gz: e7137cafd3c1d7182a0d014868c358e0f50bf78ff5bebc9a2ae1b187ab9b7db304a500c425054ac3800991ffae527735cfb6b3a5e61f74dfcd2e1a5addc5dac0
6
+ metadata.gz: 769c47a0c5a81ef93d6e264458b401fc1174f6847796c8c763ef0a258e4d3f9946761564789e1063370d8938e91af4f71b5f7b2ab5503f3de87dc3bef6579e87
7
+ data.tar.gz: 3cdfd3dcf42fa8aaf231027101be1f270e660e2488b4a7a107a52602d8e60d601d2869ee5b47f3c3831b57583c6a055fbbb9ea2ba5170b84b94f68227f9f3561
@@ -1,3 +1,7 @@
1
+ # v0.15.7
2
+
3
+ - Add `median` to --repeat-result options
4
+
1
5
  # v0.15.6
2
6
 
3
7
  - Fix new keyword argument warnings for the latest Ruby 2.7
@@ -3,7 +3,7 @@ require 'benchmark_driver/struct'
3
3
  module BenchmarkDriver
4
4
  # Repeat calling block and return desired result: "best", "worst" or "average".
5
5
  module Repeater
6
- VALID_TYPES = %w[best worst average]
6
+ VALID_TYPES = %w[best worst average median]
7
7
 
8
8
  RepeatResult = ::BenchmarkDriver::Struct.new(
9
9
  :value, # the value desired by --repeat-result
@@ -27,6 +27,8 @@ module BenchmarkDriver
27
27
  best_result(values, !larger_better)
28
28
  when 'average'
29
29
  average_result(values, rest_on_average)
30
+ when 'median'
31
+ median_result(values, rest_on_average)
30
32
  else
31
33
  raise "unexpected repeat_result #{config.repeat_result.inspect}"
32
34
  end
@@ -59,6 +61,39 @@ module BenchmarkDriver
59
61
  end
60
62
  end
61
63
 
64
+ def median_result_i(a)
65
+ b = a.dup
66
+ b.sort!
67
+ x = y = nil
68
+ until b.empty? do
69
+ x = b.pop
70
+ y = b.shift
71
+ end
72
+ x || y
73
+ end
74
+
75
+ def median_result(values, rest_on_average)
76
+ case values.first
77
+ when Numeric then
78
+ median_result values
79
+ when Array then
80
+ case rest_on_average
81
+ when :first
82
+ rest = values.first[1..-1]
83
+ median = median_result_i(values.map(&:first))
84
+ [median, *rest]
85
+ when :average
86
+ values.first.size.times.map do |i|
87
+ median_result_i(values.map {|j| j[i] })
88
+ end
89
+ else
90
+ raise "unexpected rest_on_average #{rest_on_average.inspect}"
91
+ end
92
+ else
93
+ raise "unexpected values #{values.class}"
94
+ end
95
+ end
96
+
62
97
  def extract_values(values)
63
98
  values.map do |value|
64
99
  value.is_a?(Array) ? value.first : value
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.15.6'
2
+ VERSION = '0.15.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.6
4
+ version: 0.15.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler