benchmark_driver 0.14.5 → 0.14.6

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
  SHA256:
3
- metadata.gz: 39f0184a1b8d3890b19912cd547083868ae3be9e906017cb8170b3397d58871e
4
- data.tar.gz: 49542a6ffef9e91df5455db9b3a10e6253d063a34899d7d0af6ca68402160514
3
+ metadata.gz: 35017290d925f5c26a003c0110768c477f813200cabacca2bdb6b7f1920dbdc0
4
+ data.tar.gz: 8902078f79879de35e13654710f25048d601c09ff6fd07a6f34de59d9d01c518
5
5
  SHA512:
6
- metadata.gz: d8caa0d45f6362df183d22029608469a9fb71d9884e87723e8d550c3a78b57ed942a6d01ed94179cb5ef7f616747c9bf47fe476cd035feb16360e021105364da
7
- data.tar.gz: 43087d5deb87f297af786099b537c41fa23c81fb1113e00dd2c19c7004a433ccfccb63f68bb1b4cd72448a487c383588b19870f1ed61177b815d934c34d295e8
6
+ metadata.gz: 2d94cdef0fa82b088c5d15fb697f4f555223183b263a7a69622849ddb31f0281658a062dfe00fad56fae5a6761e3d2ddb0d70137ea8c330ccad3b0a506cc7d9e
7
+ data.tar.gz: 03c250fd66144397b636a40b8437cdce619be12b084f4a441727840c79e339ddd88c82bfd0f4558672e65bc6f6ed3e0f885b8feb9314cf0e211a83ad6edfc751
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v0.14.6
2
+
3
+ - Improve option parser validation
4
+ - Add `--timeout` option only for Linux having timeout(1)
5
+ - Support `--version` option
6
+ - Fix help output for `-e`/`--rbenv` in benchmark-driver command
7
+
1
8
  # v0.14.5
2
9
 
3
10
  - Fix wrong spacing format in simple / markdown output
data/exe/benchmark-driver CHANGED
@@ -10,18 +10,18 @@ require 'yaml'
10
10
  config = BenchmarkDriver::Config.new.tap do |c|
11
11
  executables = []
12
12
  bundler = false
13
+ timeout = false
14
+
13
15
  parser = OptionParser.new do |o|
14
- o.banner = "Usage: #{File.basename($0, '.*')} [options] [YAML|RUBY]"
15
- o.on('-r', '--runner [TYPE]', 'Specify runner type: ips, time, memory, once (default: ips)') do |d|
16
- abort '-r, --runner must take argument but not given' if d.nil?
16
+ o.version = BenchmarkDriver::VERSION
17
+ o.banner = "Usage: #{File.basename($0, '.*')} [options] RUBY|YAML..."
18
+ o.on('-r', '--runner TYPE', String, 'Specify runner type: ips, time, memory, once (default: ips)') do |d|
17
19
  c.runner_type = d
18
20
  end
19
- o.on('-o', '--output [TYPE]', 'Specify output type: compare, simple, markdown, record (default: compare)') do |out|
20
- abort '-o, --output must take argument but not given' if out.nil?
21
+ o.on('-o', '--output TYPE', String, 'Specify output type: compare, simple, markdown, record (default: compare)') do |out|
21
22
  c.output_type = out
22
23
  end
23
- o.on('-e', '--executables [EXECS]', 'Ruby executables (e1::path1,arg1,...; e2::path2,arg2;...)') do |e|
24
- abort '--executable must take argument but not given' if e.nil?
24
+ o.on('-e', '--executables EXECS', String, 'Ruby executables (e1::path1 arg1; e2::path2 arg2;...)') do |e|
25
25
  e.split(';').each do |name_path|
26
26
  name, path = name_path.split('::', 2)
27
27
  path ||= name # if `::` is not given, regard whole string as path
@@ -30,20 +30,15 @@ config = BenchmarkDriver::Config.new.tap do |c|
30
30
  executables << BenchmarkDriver::Config::Executable.new(name: name, command: command)
31
31
  end
32
32
  end
33
- o.on('--rbenv [VERSIONS]', 'Ruby executables in rbenv (x.x.x,arg1,...;y.y.y,arg2,...;...)') do |r|
34
- abort '--rbenv must take argument but not given' if r.nil?
33
+ o.on('--rbenv VERSIONS', String, 'Ruby executables in rbenv (x.x.x arg1;y.y.y arg2;...)') do |r|
35
34
  r.split(';').each do |version|
36
35
  executables << BenchmarkDriver::Rbenv.parse_spec(version)
37
36
  end
38
37
  end
39
- o.on('--repeat-count [NUM]', 'Try benchmark NUM times and use the fastest result or the worst memory usage') do |v|
40
- begin
41
- c.repeat_count = Integer(v)
42
- rescue ArgumentError
43
- abort "-r, --repeat-count must take Integer, but got #{v.inspect}"
44
- end
38
+ o.on('--repeat-count NUM', Integer, 'Try benchmark NUM times and use the fastest result or the worst memory usage') do |v|
39
+ c.repeat_count = v
45
40
  end
46
- o.on('--repeat-result [TYPE]', 'Yield "best", "average" or "worst" result with --repeat-count (default: best)') do |v|
41
+ o.on('--repeat-result TYPE', String, 'Yield "best", "average" or "worst" result with --repeat-count (default: best)') do |v|
47
42
  unless BenchmarkDriver::Repeater::VALID_TYPES.include?(v)
48
43
  raise ArgumentError.new("--repeat-result must be #{BenchmarkDriver::Repeater::VALID_TYPES.join(', ')} but got #{v.inspect}")
49
44
  end
@@ -52,21 +47,24 @@ config = BenchmarkDriver::Config.new.tap do |c|
52
47
  o.on('--bundler', 'Install and use gems specified in Gemfile') do |v|
53
48
  bundler = v
54
49
  end
55
- o.on('--filter [REGEXP]', 'Filter out benchmarks with given regexp') do |v|
50
+ o.on('--filter REGEXP', String, 'Filter out benchmarks with given regexp') do |v|
56
51
  c.filters << Regexp.compile(v)
57
52
  end
58
- o.on('--run-duration [SECONDS]', 'Warmup estimates loop_count to run for this duration (default: 3)') do |v|
59
- begin
60
- c.run_duration = Float(v)
61
- rescue ArgumentError
62
- abort "--run-duration must take Float, but got #{v.inspect}"
63
- end
53
+ o.on('--run-duration SECONDS', Float, 'Warmup estimates loop_count to run for this duration (default: 3)') do |v|
54
+ c.run_duration = v
64
55
  end
56
+ o.on('--timeout SECONDS', Float, 'Timeout ruby command execution with timeout(1)') do |v|
57
+ timeout = v
58
+ end if (os = RbConfig::CONFIG['host_os']) && os.match(/linux/) && system('which timeout > /dev/null') # depending on coreutils for now...
65
59
  o.on('-v', '--verbose', 'Verbose mode. Multiple -v options increase visilibity (max: 2)') do |v|
66
60
  c.verbose += 1
67
61
  end
68
62
  end
69
- c.paths = parser.parse!(ARGV)
63
+ begin
64
+ c.paths = parser.parse!(ARGV)
65
+ rescue OptionParser::InvalidArgument => e
66
+ abort e.message
67
+ end
70
68
  if c.paths.empty?
71
69
  abort "No YAML file is specified!\n\n#{parser.help}"
72
70
  end
@@ -75,10 +73,13 @@ config = BenchmarkDriver::Config.new.tap do |c|
75
73
  unless executables.empty?
76
74
  c.executables = executables
77
75
  end
78
- if bundler
79
- c.executables.each do |exec|
76
+ c.executables.each do |exec|
77
+ if bundler
80
78
  exec.command << '-rbundler/setup'
81
79
  end
80
+ if timeout
81
+ exec.command = ['timeout', timeout.to_s, *exec.command]
82
+ end
82
83
  end
83
84
 
84
85
  c.freeze
@@ -11,6 +11,7 @@ module BenchmarkDriver
11
11
  :repeat_count, # @param [Integer]
12
12
  :repeat_result, # @param [String]
13
13
  :run_duration, # @param [Float]
14
+ :timeout, # @param [Float,nil]
14
15
  :verbose, # @param [Integer]
15
16
  defaults: {
16
17
  runner_type: 'ips',
@@ -28,6 +29,7 @@ module BenchmarkDriver
28
29
  :repeat_count, # @param [Integer]
29
30
  :repeat_result, # @param [String]
30
31
  :run_duration, # @param [Float]
32
+ :timeout, # @param [Float,nil]
31
33
  :verbose, # @param [Integer]
32
34
  )
33
35
 
@@ -20,12 +20,10 @@ module BenchmarkDriver
20
20
  end
21
21
  end
22
22
 
23
- runner_config = Config::RunnerConfig.new(
24
- repeat_count: config.repeat_count,
25
- repeat_result: config.repeat_result,
26
- run_duration: config.run_duration,
27
- verbose: config.verbose,
28
- )
23
+ runner_config = Config::RunnerConfig.new
24
+ runner_config.members.each do |member|
25
+ runner_config[member] = config[member]
26
+ end
29
27
 
30
28
  jobs.group_by{ |j| j.respond_to?(:contexts) && j.contexts }.each do |contexts, contexts_jobs|
31
29
  contexts_jobs.group_by(&:metrics).each do |metrics, metrics_jobs|
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.14.5'
2
+ VERSION = '0.14.6'
3
3
  end
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.14.5
4
+ version: 0.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler