benchmark_driver 0.4.5 → 0.5.0
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 -0
- data/exe/benchmark-driver +11 -4
- data/lib/benchmark/driver/bundle_installer.rb +45 -0
- data/lib/benchmark/driver/configuration.rb +2 -2
- data/lib/benchmark/driver/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c1a2237caaf4724bad8d5d6e01594121e33c24c4d13c5a69dc538bb4c7d56a
|
4
|
+
data.tar.gz: f1ed23287e7b4966aeb8ed53413839362d559e929d8307af793823262ce289df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0c550707bae9de4611c4ee66a30da4c99baf7d511496bf59d77dc914ff6635f780ce3163d90b2c0b04d0882042fada002093b15908c098f47dfe3a1217419c
|
7
|
+
data.tar.gz: 2a20c835711a51424b56d70887c921cf734031260b3443454e9ab9bed53c2db62a3e11b2da56279248af606a21b10ffa61e7ee7d5a84b9b5cb5e56cdd410b0c6
|
data/CHANGELOG.md
CHANGED
data/exe/benchmark-driver
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
$:.unshift File.expand_path('../lib', __dir__)
|
3
3
|
|
4
4
|
require 'benchmark/driver'
|
5
|
+
require 'benchmark/driver/bundle_installer'
|
5
6
|
require 'benchmark/driver/yaml_parser'
|
6
7
|
require 'optparse'
|
7
8
|
require 'yaml'
|
8
9
|
|
9
10
|
options = {}
|
10
|
-
|
11
|
+
parser = OptionParser.new do |o|
|
11
12
|
o.banner = "Usage: #{File.basename($0, '.*')} [options] [YAML]"
|
12
13
|
o.on('-e', '--executables [EXECS]', 'Ruby executables (e1::path1,arg1,...; e2::path2,arg2;...)') do |e|
|
14
|
+
abort '-e, --executable must take argument but not given' if e.nil?
|
13
15
|
options[:execs] ||= []
|
14
16
|
e.split(';').each do |name_path|
|
15
17
|
name, path = name_path.split('::', 2)
|
@@ -17,6 +19,7 @@ args = OptionParser.new do |o|
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
o.on('--rbenv [VERSIONS]', 'Ruby executables in rbenv (x.x.x,arg1,...;y.y.y,arg2,...;...)') do |r|
|
22
|
+
abort '--rbenv must take argument but not given' if r.nil?
|
20
23
|
options[:execs] ||= []
|
21
24
|
r.split(';').each do |spec|
|
22
25
|
version, *args = spec.split(',')
|
@@ -39,14 +42,17 @@ args = OptionParser.new do |o|
|
|
39
42
|
abort '--filter can be used only once' if options.key?(:filter)
|
40
43
|
options[:filter] = v
|
41
44
|
end
|
42
|
-
o.on('--bundler', '
|
45
|
+
o.on('--bundler', 'Install and use gems specified in Gemfile') do |v|
|
43
46
|
options[:bundler] = v
|
44
47
|
end
|
45
48
|
o.on('--dir', 'Override __dir__ from "/tmp" to actual directory of YAML') do |v|
|
46
49
|
options[:dir] = v
|
47
50
|
end
|
48
|
-
end
|
49
|
-
|
51
|
+
end
|
52
|
+
args = parser.parse!(ARGV)
|
53
|
+
if args.empty?
|
54
|
+
abort "No YAML file is specified!\n\n#{parser.help}"
|
55
|
+
end
|
50
56
|
|
51
57
|
args.each do |path|
|
52
58
|
yaml = YAML.load(File.read(path))
|
@@ -70,6 +76,7 @@ args.each do |path|
|
|
70
76
|
case key
|
71
77
|
when :bundler
|
72
78
|
config.runner_options.executables.each do |executable|
|
79
|
+
Benchmark::Driver::BundleInstaller.bundle_install_for(executable)
|
73
80
|
executable.command << '-rbundler/setup'
|
74
81
|
end
|
75
82
|
when :compare
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# TODO: Support Windows... This depends on availability of which(1)
|
4
|
+
module Benchmark::Driver::BundleInstaller
|
5
|
+
class << self
|
6
|
+
# @param [Benchmark::Driver::Configuration::Executable] executable
|
7
|
+
def bundle_install_for(executable)
|
8
|
+
ruby_path = IO.popen(['which', executable.command.first], &:read).rstrip
|
9
|
+
unless $?.success?
|
10
|
+
abort "#{executable.command.first.dump} command was not found to execute `bundle install`"
|
11
|
+
end
|
12
|
+
|
13
|
+
bundler_path = Pathname.new(ruby_path).dirname.join('bundle')
|
14
|
+
unless bundler_path.executable?
|
15
|
+
abort "#{bundler_path.to_s.dump} was not a bundler executable, whose path was guessed from #{ruby_path.dump}"
|
16
|
+
end
|
17
|
+
bundle = bundler_path.to_s
|
18
|
+
|
19
|
+
Bundler.with_clean_env do
|
20
|
+
bundle_check(bundle, ruby: executable.name) || bundle_install(bundle)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# @param [String] bundle - full path to bundle(1)
|
27
|
+
# @param [String] ruby - name of ruby
|
28
|
+
# @return [TrueClass,FalseClass] - true if success
|
29
|
+
def bundle_check(bundle, ruby:)
|
30
|
+
output = IO.popen([bundle, 'check'], &:read)
|
31
|
+
$?.success?.tap do |success|
|
32
|
+
unless success
|
33
|
+
$stderr.puts("For #{ruby}:")
|
34
|
+
$stderr.print(output)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param [String] bundle - full path to bundle(1)
|
40
|
+
def bundle_install(bundle)
|
41
|
+
pid = Process.spawn(bundle, 'install', '-j', ENV.fetch('BUNDLE_JOBS', '4'))
|
42
|
+
Process.wait(pid)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -21,7 +21,7 @@ class Benchmark::Driver::Configuration < Struct.new(:jobs, :runner_options, :out
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param [String] name
|
24
|
-
# @param [Array<String>] command
|
24
|
+
# @param [Array<String>] command - ["ruby", "-w", ...]. First element should be path to ruby command
|
25
25
|
Executable = Struct.new(:name, :command)
|
26
26
|
|
27
27
|
DEFAULT_EXECUTABLES = [Executable.new(RUBY_VERSION, [RbConfig.ruby])]
|
@@ -32,7 +32,7 @@ class Benchmark::Driver::Configuration < Struct.new(:jobs, :runner_options, :out
|
|
32
32
|
class RunnerOptions < Struct.new(:type, :executables, :repeat_count)
|
33
33
|
def initialize(*)
|
34
34
|
super
|
35
|
-
self.executables
|
35
|
+
self.executables ||= DEFAULT_EXECUTABLES
|
36
36
|
end
|
37
37
|
|
38
38
|
def executables_specified?
|
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.5.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: 2017-12-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- exe/benchmark-driver
|
78
78
|
- lib/benchmark/driver.rb
|
79
79
|
- lib/benchmark/driver/benchmark_result.rb
|
80
|
+
- lib/benchmark/driver/bundle_installer.rb
|
80
81
|
- lib/benchmark/driver/configuration.rb
|
81
82
|
- lib/benchmark/driver/duration_runner.rb
|
82
83
|
- lib/benchmark/driver/error.rb
|