benchmark_driver 0.14.22 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/exe/benchmark-driver +14 -1
- data/lib/benchmark_driver/config.rb +2 -0
- data/lib/benchmark_driver/output.rb +24 -7
- data/lib/benchmark_driver/output/all.rb +10 -2
- data/lib/benchmark_driver/runner.rb +1 -0
- data/lib/benchmark_driver/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc06a22a6f3a22dd745264633e05acabc91a4696625f9e7958532e7de728f63
|
4
|
+
data.tar.gz: 8ba559f9a31adc785a65ae018aa4f552469570b08f3c679bc69e17429a1e50a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04dcd4ad580bc8980c33469c2a3df0301c1fc272d8612246c02b095cfe37f46db13f787b678beafe3144869622c83ad91403036419e25b525aaa3e756d7f75c0
|
7
|
+
data.tar.gz: 43f9701dd9c6100fe9ec317f443bb09ab4410113b0b14acc1417ae0b748cd6b8abe9c2d26fedd4f365d2f67419c54311d774a4c6be4b37707d98861f7295ef19
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v0.15.0
|
2
|
+
|
3
|
+
- Introduce output plugin interface to accept arbitrary `--output-xxx` option
|
4
|
+
- Hide `--rbenv` option when `rbenv` command is not available
|
5
|
+
|
6
|
+
# v0.14.22
|
7
|
+
|
8
|
+
- Fix warnings for keyword arguments in Ruby 2.7
|
9
|
+
|
1
10
|
# v0.14.21
|
2
11
|
|
3
12
|
- Avoid crashinig on a zero division error in `compare` output
|
data/exe/benchmark-driver
CHANGED
@@ -20,6 +20,19 @@ config = BenchmarkDriver::Config.new.tap do |c|
|
|
20
20
|
end
|
21
21
|
o.on('-o', '--output TYPE', String, 'Specify output type: compare, simple, markdown, record (default: compare)') do |out|
|
22
22
|
c.output_type = out
|
23
|
+
begin
|
24
|
+
plugin_options = BenchmarkDriver::Output.get(out).const_get('OPTIONS', false)
|
25
|
+
rescue ArgumentError, LoadError, NameError
|
26
|
+
else
|
27
|
+
plugin_options.each do |name, args|
|
28
|
+
unless args.first.start_with?('--output-')
|
29
|
+
raise ArgumentError.new("#{args.first.dump} must start with '--output-'")
|
30
|
+
end
|
31
|
+
o.on(*args) do |opt|
|
32
|
+
c.output_opts[name] = opt
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
23
36
|
end
|
24
37
|
o.on('-e', '--executables EXECS', String, 'Ruby executables (e1::path1 arg1; e2::path2 arg2;...)') do |e|
|
25
38
|
e.split(';').each do |name_path|
|
@@ -34,7 +47,7 @@ config = BenchmarkDriver::Config.new.tap do |c|
|
|
34
47
|
r.split(';').each do |version|
|
35
48
|
executables << BenchmarkDriver::Rbenv.parse_spec(version)
|
36
49
|
end
|
37
|
-
end
|
50
|
+
end if system('which rbenv > /dev/null')
|
38
51
|
o.on('--repeat-count NUM', Integer, 'Try benchmark NUM times and use the fastest result or the worst memory usage') do |v|
|
39
52
|
c.repeat_count = v
|
40
53
|
end
|
@@ -6,6 +6,7 @@ module BenchmarkDriver
|
|
6
6
|
Config = ::BenchmarkDriver::Struct.new(
|
7
7
|
:runner_type, # @param [String]
|
8
8
|
:output_type, # @param [String]
|
9
|
+
:output_opts, # @param [Hash{ Symbol => Object }]
|
9
10
|
:paths, # @param [Array<String>]
|
10
11
|
:executables, # @param [Array<BenchmarkDriver::Config::Executable>]
|
11
12
|
:filters, # @param [Array<Regexp>]
|
@@ -17,6 +18,7 @@ module BenchmarkDriver
|
|
17
18
|
defaults: {
|
18
19
|
runner_type: 'ips',
|
19
20
|
output_type: 'compare',
|
21
|
+
output_opts: {},
|
20
22
|
filters: [],
|
21
23
|
repeat_count: 1,
|
22
24
|
repeat_result: 'best',
|
@@ -20,6 +20,17 @@ module BenchmarkDriver
|
|
20
20
|
require 'benchmark_driver/output/record'
|
21
21
|
require 'benchmark_driver/output/simple'
|
22
22
|
|
23
|
+
# @param [String] type
|
24
|
+
def self.get(type)
|
25
|
+
if type.include?(':')
|
26
|
+
raise ArgumentError.new("Output type '#{type}' cannot contain ':'")
|
27
|
+
end
|
28
|
+
|
29
|
+
require "benchmark_driver/output/#{type}" # for plugin
|
30
|
+
camelized = type.split('_').map(&:capitalize).join
|
31
|
+
::BenchmarkDriver::Output.const_get(camelized, false)
|
32
|
+
end
|
33
|
+
|
23
34
|
# BenchmarkDriver::Output is pluggable.
|
24
35
|
# Create `BenchmarkDriver::Output::Foo` as benchmark_dirver-output-foo.gem and specify `-o foo`.
|
25
36
|
#
|
@@ -27,18 +38,24 @@ module BenchmarkDriver
|
|
27
38
|
# @param [Array<BenchmarkDriver::Metric>] metrics
|
28
39
|
# @param [Array<BenchmarkDriver::Job>] jobs
|
29
40
|
# @param [Array<BenchmarkDriver::Context>] contexts
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
# @param [Hash{ Symbol => Object }] options
|
42
|
+
def initialize(type:, metrics:, jobs:, contexts:, options:)
|
43
|
+
output = ::BenchmarkDriver::Output.get(type)
|
44
|
+
output_params = output.instance_method(:initialize).parameters.select do |type, _name|
|
45
|
+
type == :keyreq || type == :key
|
46
|
+
end.map(&:last)
|
34
47
|
|
35
|
-
|
36
|
-
|
48
|
+
# Optionally pass `options` to #initialize
|
49
|
+
kwargs = {}
|
50
|
+
if output_params.include?(:options)
|
51
|
+
kwargs[:options] = options
|
52
|
+
end
|
37
53
|
|
38
|
-
@output =
|
54
|
+
@output = output.new(
|
39
55
|
metrics: metrics,
|
40
56
|
jobs: jobs,
|
41
57
|
contexts: contexts,
|
58
|
+
**kwargs,
|
42
59
|
)
|
43
60
|
end
|
44
61
|
|
@@ -2,14 +2,19 @@ class BenchmarkDriver::Output::All
|
|
2
2
|
NAME_LENGTH = 20
|
3
3
|
CONTEXT_LENGTH = 20
|
4
4
|
|
5
|
+
OPTIONS = {
|
6
|
+
sort: ['--output-sort true|false', TrueClass, 'Sort all output or not (default: true)'],
|
7
|
+
}
|
8
|
+
|
5
9
|
# @param [Array<BenchmarkDriver::Metric>] metrics
|
6
10
|
# @param [Array<BenchmarkDriver::Job>] jobs
|
7
11
|
# @param [Array<BenchmarkDriver::Context>] contexts
|
8
|
-
def initialize(metrics:, jobs:, contexts:)
|
12
|
+
def initialize(metrics:, jobs:, contexts:, options:)
|
9
13
|
@metrics = metrics
|
10
14
|
@job_names = jobs.map(&:name)
|
11
15
|
@context_names = contexts.map(&:name)
|
12
16
|
@name_length = [@job_names.map(&:length).max, NAME_LENGTH].max
|
17
|
+
@sort = options.fetch(:sort, true)
|
13
18
|
end
|
14
19
|
|
15
20
|
def with_warmup(&block)
|
@@ -67,7 +72,10 @@ class BenchmarkDriver::Output::All
|
|
67
72
|
else
|
68
73
|
print("\e[#{num_values}F")
|
69
74
|
end
|
70
|
-
@context_values[@context] = result.all_values.values.first
|
75
|
+
@context_values[@context] = result.all_values.values.first
|
76
|
+
if @sort
|
77
|
+
@context_values[@context] = @context_values[@context].sort
|
78
|
+
end
|
71
79
|
|
72
80
|
precision = result.values.values.first.to_s.sub(/\A\d+\./, '').length
|
73
81
|
num_values.times do |i|
|
@@ -36,6 +36,7 @@ module BenchmarkDriver
|
|
36
36
|
metrics: metrics,
|
37
37
|
jobs: klass_jobs.map { |job| BenchmarkDriver::Job.new(name: job.name) },
|
38
38
|
contexts: contexts,
|
39
|
+
options: config.output_opts,
|
39
40
|
)
|
40
41
|
with_clean_env do
|
41
42
|
runner.new(config: runner_config, output: output, contexts: contexts).run(klass_jobs)
|
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.
|
4
|
+
version: 0.15.0
|
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-
|
11
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.0.
|
147
|
+
rubygems_version: 3.0.3
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Fully-featured accurate benchmark driver for Ruby
|