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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1dd8df7fee30ffcc5a49d82cdd276ba4809d11f
4
- data.tar.gz: d415b2d50e9bcb381e82b4ff72c8b73ea7f43e02
3
+ metadata.gz: c0ee94f8c79245195b7f99fd9df77f485fe65be5
4
+ data.tar.gz: 3796376a848335e72ddd3154526d0ced4cc3cc8c
5
5
  SHA512:
6
- metadata.gz: 579465023608edfc4d585be52b0155d9e764e72ddad56b45e451838e073740148ee44a2ea7f93916ae9562dd435fdac63ad4b7cabe776d1690b30ac4fa82ac32
7
- data.tar.gz: 0427471a8a5c01dfbe4f543bbc959de2f599e05e4bf39943b886ef8ef64e3adf9d81a4746b309d4262ab62d86b57affb6f51b121de3278b48e506b2856699e79
6
+ metadata.gz: 630d4342c798cf476c2e603a07d9fa0047e2437892a3da2a56dd2f5f834cf906814c822d9165f895e514b221eb5ef6426fc605cce8bf88f27d34802b9fa3281a
7
+ data.tar.gz: 332d676db6aba74c977ba79aea71f722af25ad9c66b3b31ee6f44df266964a1ec398f746a560defa2ade94ce2bc3bfd939c80bd086dac576ac73ba1f62774748
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ # v0.4.4
2
+
3
+ - Add `--bundler` option to run benchmark with fixed gems
4
+
1
5
  # v0.4.3
2
6
 
3
- - Add `--filter` to run only specified benchmarks
7
+ - Add `--filter` option to run only specified benchmarks
4
8
 
5
9
  # v0.4.2
6
10
 
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] path
25
- Executable = Struct.new(:name, :path)
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
@@ -1,5 +1,5 @@
1
1
  module Benchmark
2
2
  module Driver
3
- VERSION = '0.4.3'
3
+ VERSION = '0.4.4'
4
4
  end
5
5
  end
@@ -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.path),
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.path, script_path], err: [:child, :out], &:read) }
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(path = RbConfig.ruby)
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(path, benchmark.full_script(times)) -
140
- measure_seconds(path, benchmark.overhead_script(times))
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(ruby, script)
152
+ def measure_seconds(command, script)
153
153
  with_file(script) do |path|
154
- cmd = [ruby, path].shelljoin
154
+ cmd = [*command, path].shelljoin
155
155
 
156
156
  Bundler.with_clean_env do
157
157
  before = Benchmark::Driver::Time.now
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun