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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/benchmark_driver/repeater.rb +36 -1
- data/lib/benchmark_driver/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad73033408aa70dae54e87ff9fbcfee14ba00ecf22201113f3f09083c57e9781
|
4
|
+
data.tar.gz: d6bc8f3296d6cbc1565a3fd69e69ad6eda942a72d7b5d388f415b81911f11339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769c47a0c5a81ef93d6e264458b401fc1174f6847796c8c763ef0a258e4d3f9946761564789e1063370d8938e91af4f71b5f7b2ab5503f3de87dc3bef6579e87
|
7
|
+
data.tar.gz: 3cdfd3dcf42fa8aaf231027101be1f270e660e2488b4a7a107a52602d8e60d601d2869ee5b47f3c3831b57583c6a055fbbb9ea2ba5170b84b94f68227f9f3561
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|