benchmark_driver 0.15.2 → 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1b03531aa95431a3b14d347576fdda952edec874a81ddef8ad215da14c715bb
4
- data.tar.gz: d0c84c6bcca84b668df6c75c4e4a7f61bb95026b9a94564da838783944991cee
3
+ metadata.gz: bd29e2900712c65a6309f5cfdf39bb57b2d2943527486393afadd001b63c10a2
4
+ data.tar.gz: 8c098e876e70d1fdde41cb6ece94109b53a96ca93ec0ad2a5e87013ce23b983c
5
5
  SHA512:
6
- metadata.gz: 4cc3d7e20180d63c75110d0495fbe2828d4aec30fd3ade04da6825dfc452ffdb8250f36b65800d406a5895c932296b87a3d30fd2356c3f5e2f068aa6602eea16
7
- data.tar.gz: 30e118e3b54685fe0c4baea6e3b703653600d6aa2a1bb60b31fa6e64d6e83d0feb1b363b0935007e60765ba6a85dc9718437e1b8545888774d00cf0951768d95
6
+ metadata.gz: 34d30bd25d67c10e916294acd72bbdb53d8a0d54ed4b9596780a7d89710f0d32f097702a60cafee3a1844912563b75b871a3b6496a1a1698b1454b62b9a32c4b
7
+ data.tar.gz: fa768309b8da1382630a4954bac333bd716d38913dcb3f390e2eeff4f942d6cfba619f010ea9522344bc8be4227191dd3ddf3901eed1d529fc7cce52b4d4014d
@@ -1,3 +1,7 @@
1
+ # v0.15.3
2
+
3
+ - Add `--ridkuse` to select Ruby by `ridk use` if `ridk` command is available
4
+
1
5
  # v0.15.2
2
6
 
3
7
  - `recorded` runner propagates `all_values` to output
@@ -47,7 +47,12 @@ config = BenchmarkDriver::Config.new.tap do |c|
47
47
  r.split(';').each do |version|
48
48
  executables << BenchmarkDriver::Rbenv.parse_spec(version)
49
49
  end
50
- end if system('which rbenv > /dev/null')
50
+ end if system("which rbenv > #{File::NULL}")
51
+ o.on('--ridkuse VERSIONS', String, 'Ruby executables in ridk use (x.x.x arg1;y.y.y arg2;...) for RubyInstaller2 on Windows') do |r|
52
+ r.split(';').each do |version|
53
+ executables << BenchmarkDriver::RidkUse.parse_spec(version)
54
+ end
55
+ end if system("ridk version > #{File::NULL} 2>&1")
51
56
  o.on('--repeat-count NUM', Integer, 'Try benchmark NUM times and use the fastest result or the worst memory usage') do |v|
52
57
  c.repeat_count = v
53
58
  end
@@ -68,7 +73,7 @@ config = BenchmarkDriver::Config.new.tap do |c|
68
73
  end
69
74
  o.on('--timeout SECONDS', Float, 'Timeout ruby command execution with timeout(1)') do |v|
70
75
  timeout = v
71
- end if (os = RbConfig::CONFIG['host_os']) && os.match(/linux/) && system('which timeout > /dev/null') # depending on coreutils for now...
76
+ end if (os = RbConfig::CONFIG['host_os']) && os.match(/linux/) && system("which timeout > #{File::NULL}") # depending on coreutils for now...
72
77
  o.on('-v', '--verbose', 'Verbose mode. Multiple -v options increase visilibity (max: 2)') do |v|
73
78
  c.verbose += 1
74
79
  end
@@ -4,6 +4,7 @@ require 'benchmark_driver/job_parser'
4
4
  require 'benchmark_driver/output'
5
5
  require 'benchmark_driver/rbenv'
6
6
  require 'benchmark_driver/repeater'
7
+ require 'benchmark_driver/ridkuse'
7
8
  require 'benchmark_driver/ruby_interface'
8
9
  require 'benchmark_driver/runner'
9
10
  require 'benchmark_driver/version'
@@ -0,0 +1,57 @@
1
+ require 'open3'
2
+ require 'shellwords'
3
+
4
+ module BenchmarkDriver
5
+ module RidkUse
6
+ # Execute "ridk use list" command to get a list of Ruby versions.
7
+ #
8
+ # * "ridk use list" is a sub-command of ridk. It returns a list of installed ruby ​​versions.
9
+ # * "ridk" is a helper command tool of RubyInstaller2 for Windows, that to manage the runtime environment of RubyInstaller-2.4 and up.
10
+ #
11
+ # refer to:
12
+ # {The ridk tool · oneclick/rubyinstaller2 Wiki}[https://github.com/oneclick/rubyinstaller2/wiki/The-ridk-tool]
13
+ #
14
+ def self.ridk_use_list
15
+ ruby_list = []
16
+ regex = /(\d+)\s-\s([^\s]+)\s\truby\s([^\s]+)\s/
17
+ cmd = "ridk use list"
18
+ stdout, status = Open3.capture2e(cmd)
19
+
20
+ stdout.each_line do |line|
21
+ if matched = regex.match(line)
22
+ idx, rubypath, rubyver = matched[1..3]
23
+ ruby_list << rubyver << [idx, "#{rubypath}/bin/ruby.exe"]
24
+ else
25
+ abort "Failed to execute 'ridk use list'"
26
+ end
27
+ end
28
+ Hash[*ruby_list]
29
+ end
30
+
31
+ # @param [String] version
32
+ def self.ruby_path(version)
33
+ ruby_list = BenchmarkDriver::RidkUse.ridk_use_list
34
+ regex = Regexp.new(version)
35
+ matched = ruby_list.keys.find {|k| k =~ regex}
36
+
37
+ if ruby_list.has_key?(version)
38
+ ruby_list[version][1]
39
+ elsif matched
40
+ ruby_list[matched][1]
41
+ else
42
+ abort "version #{version} not found"
43
+ end
44
+ end
45
+
46
+ # @param [String] full_spec - "2.6.3", "2.6.3p62", "2.6.3,--jit", etc.
47
+ def self.parse_spec(full_spec)
48
+ name, spec = full_spec.split('::', 2)
49
+ spec ||= name # if `::` is not given, regard whole string as spec
50
+ version, *args = spec.shellsplit
51
+ BenchmarkDriver::Config::Executable.new(
52
+ name: name,
53
+ command: [BenchmarkDriver::RidkUse.ruby_path(version), *args],
54
+ )
55
+ end
56
+ end
57
+ end
@@ -71,6 +71,13 @@ module BenchmarkDriver
71
71
  end
72
72
  end
73
73
 
74
+ # ridk use command for RubyInstaller2 on Windows
75
+ def ridkuse(*versions)
76
+ versions.each do |version|
77
+ @executables << BenchmarkDriver::RidkUse.parse_spec(version)
78
+ end
79
+ end
80
+
74
81
  def executable(name:, command:)
75
82
  raise ArgumentError, "`command' should be an Array" unless command.kind_of? Array
76
83
  @executables << BenchmarkDriver::Config::Executable.new(name: name, command: command)
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.15.2'
2
+ VERSION = '0.15.3'
3
3
  end
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.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -113,6 +113,7 @@ files:
113
113
  - lib/benchmark_driver/output/simple.rb
114
114
  - lib/benchmark_driver/rbenv.rb
115
115
  - lib/benchmark_driver/repeater.rb
116
+ - lib/benchmark_driver/ridkuse.rb
116
117
  - lib/benchmark_driver/ruby_interface.rb
117
118
  - lib/benchmark_driver/runner.rb
118
119
  - lib/benchmark_driver/runner/block.rb