benchmark_driver 0.15.18 → 0.16.1

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: 056db37cfc1c2453c9ab994d4b1241bb450ad7e138e69e2ae4a5995825976753
4
- data.tar.gz: f827c814001e175ebcb878181ff0b6b411466bb34bf4ff4a34e02b0f1fdafdda
3
+ metadata.gz: 2aa17cc07885ff406870c16844aa57b9230f81a1be2104627af5e21131ba9fb9
4
+ data.tar.gz: 6b3d0dfcc8fe50785811a98eb1d62093a90463150aff7eb7d1773c07a9c72391
5
5
  SHA512:
6
- metadata.gz: f34f11c0d5a30be2e232af08d00e2e1b2420a161aa18c1f020a0f342f53804b82da754c61632a008ec7822f710edab2af7a1dde18cf1a67a4e51ab14852b3b3a
7
- data.tar.gz: e0601d752e1f55d95ae2c1b83f6dfaa432290b28856ceca553500597f8b06b508c34909df98cd96f3aaf0989df9d2ef76fa0c1e31099f80486b37fa641ce15dd
6
+ metadata.gz: dc65698d4628c758ec49a32769d9f4e86c1b3d2721777227e7bca285c32b75687e7ec05d93351c4df37ed789e1d96fb0e717fe56440b972e34f03ce04341ca9b
7
+ data.tar.gz: 139315d91d21b9f86a276a3257eec66bdff8f317dd358619d99a6fcdcafabbe9e1fb9a9837b4607f97dbcc2df911b0d11ac128d228c10c644d7336cecbf396e8
@@ -0,0 +1,36 @@
1
+ name: test
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ types:
8
+ - opened
9
+ - synchronize
10
+ - reopened
11
+ schedule:
12
+ - cron: "00 15 * * *"
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby:
19
+ - '2.5'
20
+ - '2.6'
21
+ - '2.7'
22
+ - '3.0'
23
+ - '3.1'
24
+ fail-fast: false
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler-cache: true
32
+ - name: Install benchmark targets
33
+ run: |
34
+ gem install haml -v 4.0.7
35
+ gem install haml -v 5.0.4
36
+ - run: VERBOSE=1 bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # v0.16.1
2
+
3
+ - Add --output-humanize option to --output=simple
4
+
5
+ # v0.16.0
6
+
7
+ - Support benchmarking inline Ruby scripts [#75](https://github.com/benchmark-driver/benchmark-driver/pull/75)
8
+ - Require Ruby 2.5+
9
+ - Fix `recorded` runner for Ruby 3.1's Psych
10
+
1
11
  # v0.15.18
2
12
 
3
13
  - Mention `--output=all` in help
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # BenchmarkDriver [![Build Status](https://travis-ci.org/benchmark-driver/benchmark-driver.svg?branch=master)](https://travis-ci.org/benchmark-driver/benchmark-driver)
1
+ # BenchmarkDriver
2
2
 
3
3
  Fully-featured accurate benchmark driver for Ruby
4
4
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = 'exe'
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
- spec.required_ruby_version = '>= 2.2.0'
22
+ spec.required_ruby_version = '>= 2.5.0'
23
23
 
24
24
  spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake'
data/exe/benchmark-driver CHANGED
@@ -87,11 +87,11 @@ config = BenchmarkDriver::Config.new.tap do |c|
87
87
  end
88
88
  end
89
89
  begin
90
- c.paths = parser.parse!(ARGV)
90
+ c.args = parser.parse!(ARGV)
91
91
  rescue OptionParser::InvalidArgument => e
92
92
  abort e.message
93
93
  end
94
- if c.paths.empty?
94
+ if c.args.empty?
95
95
  abort "No YAML file is specified!\n\n#{parser.help}"
96
96
  end
97
97
 
@@ -112,24 +112,32 @@ config = BenchmarkDriver::Config.new.tap do |c|
112
112
  end
113
113
 
114
114
  # Parse benchmark job definitions
115
- jobs = config.paths.flat_map do |path|
115
+ jobs = config.args.flat_map do |arg|
116
116
  job = { 'type' => config.runner_type }
117
117
 
118
- # Treat *.rb as a single-execution benchmark, others are considered as YAML definition
119
- if path.end_with?('.rb')
120
- name = File.basename(path).sub(/\.rb\z/, '')
121
- script = File.read(path)
118
+ # Three types of input:
119
+ # * YAML file (*.yml, *.yaml): a regular benchmark with various params
120
+ # * Ruby file (*.rb): a single-execution benchmark
121
+ # * Ruby inline (any other argument): a multi-execution benchmark
122
+ if arg.end_with?('.yml') || arg.end_with?('.yaml')
123
+ yaml = File.read(arg)
124
+ job.merge!(YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml) : YAML.load(yaml))
125
+ elsif arg.end_with?('.rb')
126
+ name = File.basename(arg).sub(/\.rb\z/, '')
127
+ script = File.read(arg)
122
128
  prelude = script.slice!(/\A(^#[^\n]+\n)+/m) || '' # preserve magic comment
123
129
  job.merge!('prelude' => prelude, 'benchmark' => { name => script }, 'loop_count' => 1)
124
- else
125
- job.merge!(YAML.load_file(path))
130
+ else # Ruby inline
131
+ job.merge!('benchmark' => { arg => arg })
132
+ working_directory = Dir.pwd
126
133
  end
134
+ working_directory ||= File.expand_path(File.dirname(arg))
127
135
 
128
136
  begin
129
137
  # `working_directory` is YAML-specific special parameter, mainly for "command_stdout"
130
- BenchmarkDriver::JobParser.parse(job, working_directory: File.expand_path(File.dirname(path)))
138
+ BenchmarkDriver::JobParser.parse(job, working_directory: working_directory)
131
139
  rescue ArgumentError
132
- $stderr.puts "benchmark-driver: Failed to parse #{path.dump}."
140
+ $stderr.puts "benchmark-driver: Failed to parse #{arg.dump}."
133
141
  $stderr.puts ' YAML format may be wrong. See error below:'
134
142
  $stderr.puts
135
143
  raise
@@ -8,7 +8,7 @@ module BenchmarkDriver
8
8
  :runner_type, # @param [String]
9
9
  :output_type, # @param [String]
10
10
  :output_opts, # @param [Hash{ Symbol => Object }]
11
- :paths, # @param [Array<String>]
11
+ :args, # @param [Array<String>]
12
12
  :executables, # @param [Array<BenchmarkDriver::Config::Executable>]
13
13
  :filters, # @param [Array<Regexp>]
14
14
  :repeat_count, # @param [Integer]
@@ -1,13 +1,18 @@
1
1
  class BenchmarkDriver::Output::Simple
2
2
  NAME_LENGTH = 10
3
3
 
4
+ OPTIONS = {
5
+ humanize: ['--output-humanize true|false', TrueClass, 'Humanize result numbers (default: true)'],
6
+ }
7
+
4
8
  # @param [Array<BenchmarkDriver::Metric>] metrics
5
9
  # @param [Array<BenchmarkDriver::Job>] jobs
6
10
  # @param [Array<BenchmarkDriver::Context>] contexts
7
- def initialize(metrics:, jobs:, contexts:)
11
+ def initialize(metrics:, jobs:, contexts:, options:)
8
12
  @metrics = metrics
9
13
  @context_names = contexts.map(&:name)
10
14
  @name_length = jobs.map(&:name).map(&:size).max
15
+ @humanize = options.fetch(:humanize, true)
11
16
  end
12
17
 
13
18
  def with_warmup(&block)
@@ -78,6 +83,8 @@ class BenchmarkDriver::Output::Simple
78
83
  end
79
84
 
80
85
  def humanize(value)
86
+ return value unless @humanize
87
+
81
88
  if BenchmarkDriver::Result::ERROR.equal?(value)
82
89
  return " %#{NAME_LENGTH}s" % 'ERROR'
83
90
  elsif value == 0.0
@@ -1,3 +1,3 @@
1
1
  module BenchmarkDriver
2
- VERSION = '0.15.18'
2
+ VERSION = '0.16.1'
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.15.18
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,9 +74,9 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".github/workflows/test.yml"
77
78
  - ".gitignore"
78
79
  - ".rspec"
79
- - ".travis.yml"
80
80
  - CHANGELOG.md
81
81
  - Gemfile
82
82
  - LICENSE.txt
@@ -131,7 +131,7 @@ homepage: https://github.com/benchmark-driver/benchmark-driver
131
131
  licenses:
132
132
  - MIT
133
133
  metadata: {}
134
- post_install_message:
134
+ post_install_message:
135
135
  rdoc_options: []
136
136
  require_paths:
137
137
  - lib
@@ -139,15 +139,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
- version: 2.2.0
142
+ version: 2.5.0
143
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  requirements:
145
145
  - - ">="
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.1.2
150
- signing_key:
149
+ rubygems_version: 3.3.7
150
+ signing_key:
151
151
  specification_version: 4
152
152
  summary: Fully-featured accurate benchmark driver for Ruby
153
153
  test_files: []
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.8
4
- - 2.4.9
5
- - 2.5.7
6
- - 2.6.5
7
- - 2.7.0
8
- - ruby-head
9
- matrix:
10
- allow_failures:
11
- - rvm: ruby-head
12
- cache: bundler
13
- branches:
14
- only:
15
- - master
16
- before_install:
17
- - gem install bundler -v 1.15.4
18
- - gem install haml -v 4.0.7
19
- - gem install haml -v 5.0.4
20
- script:
21
- - VERBOSE=1 bundle exec rake