benchmark_driver 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/exe/benchmark-driver +14 -4
- data/lib/benchmark/driver/configuration.rb +3 -3
- data/lib/benchmark/driver/version.rb +1 -1
- data/lib/benchmark/runner/exec.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0ee94f8c79245195b7f99fd9df77f485fe65be5
|
4
|
+
data.tar.gz: 3796376a848335e72ddd3154526d0ced4cc3cc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 630d4342c798cf476c2e603a07d9fa0047e2437892a3da2a56dd2f5f834cf906814c822d9165f895e514b221eb5ef6426fc605cce8bf88f27d34802b9fa3281a
|
7
|
+
data.tar.gz: 332d676db6aba74c977ba79aea71f722af25ad9c66b3b31ee6f44df266964a1ec398f746a560defa2ade94ce2bc3bfd939c80bd086dac576ac73ba1f62774748
|
data/CHANGELOG.md
CHANGED
data/exe/benchmark-driver
CHANGED
@@ -13,7 +13,7 @@ args = OptionParser.new do |o|
|
|
13
13
|
options[:execs] ||= []
|
14
14
|
e.split(';').each do |name_path|
|
15
15
|
name, path = name_path.split('::', 2)
|
16
|
-
options[:execs] << Benchmark::Driver::Configuration::Executable.new(name, path || name)
|
16
|
+
options[:execs] << Benchmark::Driver::Configuration::Executable.new(name, [path || name])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
o.on('--rbenv [VERSIONS]', 'Ruby executables in rbenv (2.3.5;2.4.2;...)') do |r|
|
@@ -21,7 +21,7 @@ args = OptionParser.new do |o|
|
|
21
21
|
r.split(';').each do |version|
|
22
22
|
path = `RBENV_VERSION='#{version}' rbenv which ruby`.rstrip
|
23
23
|
abort "Failed to execute 'rbenv which ruby'" unless $?.success?
|
24
|
-
options[:execs] << Benchmark::Driver::Configuration::Executable.new(version, path)
|
24
|
+
options[:execs] << Benchmark::Driver::Configuration::Executable.new(version, [path])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
o.on('-c', '--compare', 'Compare results (currently only supported in ips output)') do |v|
|
@@ -38,6 +38,9 @@ args = OptionParser.new do |o|
|
|
38
38
|
abort '--filter can be used only once' if options.key?(:filter)
|
39
39
|
options[:filter] = v
|
40
40
|
end
|
41
|
+
o.on('--bundler', 'Use gems specified in Gemfile (append -rbundler/setup)') do |v|
|
42
|
+
options[:bundler] = v
|
43
|
+
end
|
41
44
|
o.on('--dir', 'Override __dir__ from "/tmp" to actual directory of YAML') do |v|
|
42
45
|
options[:dir] = v
|
43
46
|
end
|
@@ -57,8 +60,17 @@ args.each do |path|
|
|
57
60
|
raise
|
58
61
|
end
|
59
62
|
|
63
|
+
# Proceed execs first for --bundler
|
64
|
+
if options.key?(:execs)
|
65
|
+
config.runner_options.executables = options.delete(:execs)
|
66
|
+
end
|
67
|
+
|
60
68
|
options.each do |key, value|
|
61
69
|
case key
|
70
|
+
when :bundler
|
71
|
+
config.runner_options.executables.each do |executable|
|
72
|
+
executable.command << '-rbundler/setup'
|
73
|
+
end
|
62
74
|
when :compare
|
63
75
|
config.output_options.compare = value
|
64
76
|
when :dir
|
@@ -66,8 +78,6 @@ args.each do |path|
|
|
66
78
|
config.jobs.each do |job|
|
67
79
|
job.prelude = "__dir__ = #{dir.dump}.freeze; #{job.prelude}"
|
68
80
|
end
|
69
|
-
when :execs
|
70
|
-
config.runner_options.executables = value
|
71
81
|
when :filter
|
72
82
|
filter = Regexp.compile(value)
|
73
83
|
config.jobs.select! do |job|
|
@@ -21,10 +21,10 @@ class Benchmark::Driver::Configuration < Struct.new(:jobs, :runner_options, :out
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param [String] name
|
24
|
-
# @param [String]
|
25
|
-
Executable = Struct.new(:name, :
|
24
|
+
# @param [Array<String>] command
|
25
|
+
Executable = Struct.new(:name, :command)
|
26
26
|
|
27
|
-
DEFAULT_EXECUTABLES = [Executable.new(RUBY_VERSION, RbConfig.ruby)]
|
27
|
+
DEFAULT_EXECUTABLES = [Executable.new(RUBY_VERSION, [RbConfig.ruby])]
|
28
28
|
|
29
29
|
# @param [Symbol] type - Type of runner
|
30
30
|
# @param [Array<Benchmark::Driver::Configuration::Executable>] executables
|
@@ -67,7 +67,7 @@ class Benchmark::Runner::Exec
|
|
67
67
|
fields = @output.class::REQUIRED_FIELDS
|
68
68
|
if fields == [:real]
|
69
69
|
Benchmark::Driver::RepeatableRunner.new(job).run(
|
70
|
-
runner: build_runner(executable.
|
70
|
+
runner: build_runner(executable.command),
|
71
71
|
repeat_count: @options.repeat_count,
|
72
72
|
).tap do |result|
|
73
73
|
if result.real < 0
|
@@ -79,7 +79,7 @@ class Benchmark::Runner::Exec
|
|
79
79
|
|
80
80
|
script = BenchmarkScript.new(job.prelude, job.script).full_script(job.loop_count)
|
81
81
|
with_file(script) do |script_path|
|
82
|
-
out = Bundler.with_clean_env { IO.popen(['/usr/bin/time', executable.
|
82
|
+
out = Bundler.with_clean_env { IO.popen(['/usr/bin/time', *executable.command, script_path], err: [:child, :out], &:read) }
|
83
83
|
match_data = /^(?<user>\d+.\d+)user\s+(?<system>\d+.\d+)system\s+(?<elapsed1>\d+):(?<elapsed2>\d+.\d+)elapsed.+\([^\s]+\s+(?<maxresident>\d+)maxresident\)k$/.match(out)
|
84
84
|
raise "Unexpected format given from /usr/bin/time:\n#{out}" unless match_data[:maxresident]
|
85
85
|
|
@@ -133,11 +133,11 @@ class Benchmark::Runner::Exec
|
|
133
133
|
|
134
134
|
# @param [String] path - Path to Ruby executable
|
135
135
|
# @return [Proc] - Lambda to run benchmark
|
136
|
-
def build_runner(
|
136
|
+
def build_runner(command = [RbConfig.ruby])
|
137
137
|
lambda do |job, times|
|
138
138
|
benchmark = BenchmarkScript.new(job.prelude, job.script)
|
139
|
-
measure_seconds(
|
140
|
-
measure_seconds(
|
139
|
+
measure_seconds(command, benchmark.full_script(times)) -
|
140
|
+
measure_seconds(command, benchmark.overhead_script(times))
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -149,9 +149,9 @@ class Benchmark::Runner::Exec
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
def measure_seconds(
|
152
|
+
def measure_seconds(command, script)
|
153
153
|
with_file(script) do |path|
|
154
|
-
cmd = [
|
154
|
+
cmd = [*command, path].shelljoin
|
155
155
|
|
156
156
|
Bundler.with_clean_env do
|
157
157
|
before = Benchmark::Driver::Time.now
|