benchmark_driver 0.10.8 → 0.10.9

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: 8b1b310f52a83e0661be59e3835573a69b7e84a7aebb7f4f13e0f190ce2545c8
4
- data.tar.gz: 3597a61936cedb14e59cf172e76cf3d5f91616ec0dd6470a54c4e51c32e7008c
3
+ metadata.gz: 4b76fb2eccae49948fe8a099509f5b2132a18e5290e76b877599d1b6a2f5375e
4
+ data.tar.gz: 3d834c25436c2d07d80757a477f460e5218fc386bb8fd7c28526451fafae0617
5
5
  SHA512:
6
- metadata.gz: b96308b5c25cae8dead511787fba95c1b049b5900e15670ccd8f84ec1b7b4584a23d2dd555c49a58c8ac32b59d4bc9715d6ffcdc964ee15761877d0986eb4ead
7
- data.tar.gz: 9a33f86af59d36209715847a39cfc6777d1d4f078203f0dfa702b330e12201b747f3a275b9d6d032d2e2322013a83bd9230fa91c12303fb97e77b67c459029a1
6
+ metadata.gz: 0f87ca0223f252f552c168562c51e90fd2500b2c331b91244bcd66f3bcaf9928903389c6ae7c1aa44d4ebe3db58bba77fcd39a3b16fa81fc1f73c2e6ef8f5d2c
7
+ data.tar.gz: 2179c5af87b4205c0db3f54e7d7ea34c14989fdf24707101ffd569d0ec27cf6834b94a76cbe74c2d98aaa7a5784f3fc7755931ac757aebfa5b86b9dc4d4504fa
@@ -1,3 +1,7 @@
1
+ # v0.10.9
2
+
3
+ - Add `x.rbenv`, `x.loop_count`, `x.verbose` supports to Ruby interface
4
+
1
5
  # v0.10.8
2
6
 
3
7
  - In `command_stdout`, `$RBENV_VERSION` is no longer passed to --rbenv option because it has no effect for rbenv
@@ -9,4 +9,5 @@ Benchmark.driver(output: :simple) do |x|
9
9
  EOS
10
10
  x.report %{ array.empty? }
11
11
  x.report %{ array.blank? }
12
+ x.loop_count 10000000
12
13
  end
@@ -31,14 +31,8 @@ config = BenchmarkDriver::Config.new.tap do |c|
31
31
  end
32
32
  o.on('--rbenv [VERSIONS]', 'Ruby executables in rbenv (x.x.x,arg1,...;y.y.y,arg2,...;...)') do |r|
33
33
  abort '--rbenv must take argument but not given' if r.nil?
34
- r.split(';').each do |full_spec|
35
- name, spec = full_spec.split('::', 2)
36
- spec ||= name # if `::` is not given, regard whole string as spec
37
- version, *args = spec.split(',')
38
- executables << BenchmarkDriver::Config::Executable.new(
39
- name: name,
40
- command: [BenchmarkDriver::Rbenv.ruby_path(version), *args],
41
- )
34
+ r.split(';').each do |version|
35
+ executables << BenchmarkDriver::Rbenv.parse_spec(version)
42
36
  end
43
37
  end
44
38
  o.on('--repeat-count [NUM]', 'Try benchmark NUM times and use the fastest result (TODO)') do |v|
@@ -1,5 +1,6 @@
1
1
  module BenchmarkDriver
2
2
  module Rbenv
3
+ # @param [String] version
3
4
  def self.ruby_path(version)
4
5
  path = `RBENV_VERSION='#{version}' rbenv which ruby`.rstrip
5
6
  unless $?.success?
@@ -7,5 +8,16 @@ module BenchmarkDriver
7
8
  end
8
9
  path
9
10
  end
11
+
12
+ # @param [String] full_spec - "2.5.0", "2.5.0,--jit", "JIT::2.5.0,--jit", etc.
13
+ def self.parse_spec(full_spec)
14
+ name, spec = full_spec.split('::', 2)
15
+ spec ||= name # if `::` is not given, regard whole string as spec
16
+ version, *args = spec.split(',')
17
+ BenchmarkDriver::Config::Executable.new(
18
+ name: name,
19
+ command: [BenchmarkDriver::Rbenv.ruby_path(version), *args],
20
+ )
21
+ end
10
22
  end
11
23
  end
@@ -6,10 +6,15 @@ module BenchmarkDriver
6
6
 
7
7
  # Build jobs and run. This is NOT interface for users.
8
8
  def run
9
+ unless @executables.empty?
10
+ @config.executables = @executables
11
+ end
12
+
9
13
  jobs = @jobs.flat_map do |job|
10
14
  BenchmarkDriver::JobParser.parse({
11
15
  type: @config.runner_type,
12
16
  prelude: @prelude,
17
+ loop_count: @loop_count,
13
18
  }.merge!(job))
14
19
  end
15
20
  BenchmarkDriver::Runner.run(jobs, config: @config)
@@ -23,10 +28,12 @@ module BenchmarkDriver
23
28
  # @param [String,NilClass] runner
24
29
  def initialize(output: nil, runner: nil)
25
30
  @prelude = ''
31
+ @loop_count = nil
26
32
  @jobs = []
27
33
  @config = BenchmarkDriver::Config.new
28
34
  @config.output_type = output.to_s if output
29
35
  @config.runner_type = runner.to_s if runner
36
+ @executables = []
30
37
  end
31
38
 
32
39
  # @param [String] script
@@ -34,6 +41,11 @@ module BenchmarkDriver
34
41
  @prelude << "#{script}\n"
35
42
  end
36
43
 
44
+ # @param [Integer] count
45
+ def loop_count(count)
46
+ @loop_count = count
47
+ end
48
+
37
49
  # @param [String] name - Name shown on result output.
38
50
  # @param [String,nil] script - Benchmarked script in String. If nil, name is considered as script too.
39
51
  def report(name, script = nil)
@@ -47,5 +59,15 @@ module BenchmarkDriver
47
59
  def compare!
48
60
  @config.output_type = 'compare'
49
61
  end
62
+
63
+ def rbenv(*versions)
64
+ versions.each do |version|
65
+ @executables << BenchmarkDriver::Rbenv.parse_spec(version)
66
+ end
67
+ end
68
+
69
+ def verbose(level = 1)
70
+ @config.verbose = level
71
+ end
50
72
  end
51
73
  end
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.10.8'
2
+ VERSION = '0.10.9'
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.10.8
4
+ version: 0.10.9
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-02-26 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler