benchmark_driver 0.10.16 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +16 -0
  5. data/README.md +25 -9
  6. data/Rakefile +5 -48
  7. data/benchmark-driver/.gitignore +12 -0
  8. data/benchmark-driver/CODE_OF_CONDUCT.md +74 -0
  9. data/benchmark-driver/Gemfile +6 -0
  10. data/benchmark-driver/LICENSE.txt +21 -0
  11. data/benchmark-driver/README.md +8 -0
  12. data/benchmark-driver/Rakefile +1 -0
  13. data/benchmark-driver/benchmark-driver.gemspec +21 -0
  14. data/benchmark-driver/bin/console +14 -0
  15. data/benchmark-driver/bin/setup +8 -0
  16. data/benchmark-driver/lib/benchmark-driver.rb +1 -0
  17. data/benchmark-driver/lib/benchmark/driver.rb +1 -0
  18. data/benchmark_driver.gemspec +3 -1
  19. data/exe/benchmark-driver +3 -3
  20. data/lib/benchmark_driver/config.rb +3 -3
  21. data/lib/benchmark_driver/metric.rb +70 -0
  22. data/lib/benchmark_driver/output.rb +62 -8
  23. data/lib/benchmark_driver/output/compare.rb +68 -52
  24. data/lib/benchmark_driver/output/markdown.rb +21 -16
  25. data/lib/benchmark_driver/output/record.rb +26 -21
  26. data/lib/benchmark_driver/output/simple.rb +21 -16
  27. data/lib/benchmark_driver/runner.rb +5 -3
  28. data/lib/benchmark_driver/runner/command_stdout.rb +19 -19
  29. data/lib/benchmark_driver/runner/ips.rb +30 -29
  30. data/lib/benchmark_driver/runner/memory.rb +15 -16
  31. data/lib/benchmark_driver/runner/once.rb +11 -15
  32. data/lib/benchmark_driver/runner/recorded.rb +28 -21
  33. data/lib/benchmark_driver/runner/ruby_stdout.rb +157 -0
  34. data/lib/benchmark_driver/runner/time.rb +7 -10
  35. data/lib/benchmark_driver/version.rb +1 -1
  36. metadata +46 -16
  37. data/examples/exec_blank.rb +0 -13
  38. data/examples/exec_blank_simple.rb +0 -13
  39. data/examples/yaml/array_duration_time.yml +0 -2
  40. data/examples/yaml/array_loop.yml +0 -3
  41. data/examples/yaml/blank_hash.yml +0 -8
  42. data/examples/yaml/blank_hash_array.yml +0 -10
  43. data/examples/yaml/blank_loop.yml +0 -9
  44. data/examples/yaml/blank_string.yml +0 -6
  45. data/examples/yaml/blank_string_array.yml +0 -8
  46. data/examples/yaml/example_multi.yml +0 -6
  47. data/examples/yaml/example_single.yml +0 -4
  48. data/lib/benchmark_driver/metrics.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 6082e75d0eda1a86f600c95730d10b0dfd1c50ce0015e3620109a975a302ac70
4
- data.tar.gz: a864a92790907f9ce4f04187f064d42d99dbb8e0c84a5daf4373da910ef9addf
2
+ SHA1:
3
+ metadata.gz: 16b3e45ce8476d4acf4e3528d04079f1346b6436
4
+ data.tar.gz: 0e4a7a94f47ba9bb596ba96904712db4c6935032
5
5
  SHA512:
6
- metadata.gz: c5cafbd01fdb7192915ac1372f173aadd62f2d19da708d2d224e1cc3044d763cb15b57037dd19efa90bbc3c85c669daa0b9a2f15ea697182888f8c2d255f8238
7
- data.tar.gz: 8108b55f9a9de835e5e42237c9cdf661ebcdb2b54ef41ce58ae02c5df8312248fed6aa76e9bc874704fe8befe2093a17a96aae712e09fb73a5d92c09717163d0
6
+ metadata.gz: 75b834584e0fc996dda837d879af768c6bab9acba07fb53f284103ec73aafd53b8b5cc82001b9067a7d0403420c97fa30f59146bcff9c3341c89cf4c003e915e
7
+ data.tar.gz: cafd73b0bdaeb3b8635a0cbc847eaf9d3b6969d80369093004db615618cab41b6e004640f81a58bd8d38389243fc4061c230473ed696b7524bc15d23bbe6d87d
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper.rb
data/.travis.yml CHANGED
@@ -10,4 +10,4 @@ branches:
10
10
  - master
11
11
  before_install: gem install bundler -v 1.15.4
12
12
  script:
13
- - bundle exec rake
13
+ - RSPEC_RETRIES=3 VERBOSE=1 bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # v0.11.0
2
+
3
+ - [breaking change] Plugin interface is completely changed, so all plugins need migration
4
+ - YAML/Ruby interface is not changed at all
5
+ - Now the internal model allows to have multiple metrics in the same job,
6
+ but having multiple metrics is still not respected by built-in plugins
7
+ - "executable" is renamed to be "context", but still configuring a context
8
+ other than an executable is not supported yet
9
+ - A metric can have a name
10
+ - Add `ruby_stdout` runner
11
+ - This can parse an arbitrary "environment" for the "context"
12
+ - Metric can have name
13
+ - Metric name is shwon on some outputs like markdown and simple
14
+ - `--run-duration` accepts floating-point number
15
+ - News: Now benchmark-driver.gem can be used as an alias to install benchmark\_driver.gem
16
+
1
17
  # v0.10.16
2
18
 
3
19
  - `command_stdout` runner uses YAML's dirname as `working_directory` by default
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # BenchmarkDriver [![Build Status](https://travis-ci.org/k0kubun/benchmark_driver.svg?branch=master)](https://travis-ci.org/k0kubun/benchmark_driver)
1
+ # BenchmarkDriver [![Build Status](https://travis-ci.org/benchmark-driver/benchmark-driver.svg?branch=master)](https://travis-ci.org/benchmark-driver/benchmark-driver)
2
2
 
3
3
  Fully-featured accurate benchmark driver for Ruby
4
4
 
@@ -168,10 +168,26 @@ Benchmark.driver do |x|
168
168
  end
169
169
  ```
170
170
 
171
+ With following `blank_loop.yml`,
172
+
173
+ ```
174
+ loop_count: 20000000
175
+ prelude: |
176
+ class Array
177
+ alias_method :blank?, :empty?
178
+ end
179
+ array = []
180
+ benchmark:
181
+ empty: array.empty?
182
+ blank: array.blank?
183
+ ```
184
+
185
+ you can output results in various ways like:
186
+
171
187
  ### compare
172
188
 
173
189
  ```
174
- $ benchmark-driver examples/yaml/blank_loop.yml --output compare --rbenv '2.4.2;2.5.0'
190
+ $ benchmark-driver blank_loop.yml --output compare --rbenv '2.4.2;2.5.0'
175
191
  Calculating -------------------------------------
176
192
  2.4.2 2.5.0
177
193
  empty 195.957M 129.970M i/s - 20.000M times in 0.102063s 0.153882s
@@ -190,7 +206,7 @@ Comparison:
190
206
  ### simple
191
207
 
192
208
  ```
193
- $ benchmark-driver examples/yaml/blank_loop.yml --output simple --rbenv '2.4.2;2.5.0'
209
+ $ benchmark-driver blank_loop.yml --output simple --rbenv '2.4.2;2.5.0'
194
210
  benchmark results (i/s):
195
211
  2.4.2 2.5.0
196
212
  empty 184.084M 117.319M
@@ -200,7 +216,7 @@ blank 65.843M 62.093M
200
216
  ### markdown
201
217
 
202
218
  ```
203
- $ benchmark-driver examples/yaml/blank_loop.yml --output markdown --rbenv '2.4.2;2.5.0'
219
+ $ benchmark-driver blank_loop.yml --output markdown --rbenv '2.4.2;2.5.0'
204
220
  ```
205
221
 
206
222
  benchmark results (i/s)
@@ -215,7 +231,7 @@ benchmark results (i/s)
215
231
  Measure first, output with various formats later.
216
232
 
217
233
  ```
218
- $ benchmark-driver examples/yaml/blank_loop.yml --output record --rbenv '2.4.2;2.5.0'
234
+ $ benchmark-driver blank_loop.yml --output record --rbenv '2.4.2;2.5.0'
219
235
  benchmarking....
220
236
 
221
237
  $ benchmark-driver benchmark_driver.record.yml --output compare
@@ -262,7 +278,7 @@ ips, time, memory, once
262
278
  ### ips
263
279
 
264
280
  ```
265
- $ benchmark-driver examples/yaml/blank_loop.yml --runner ips --rbenv '2.4.3;2.5.0'
281
+ $ benchmark-driver blank_loop.yml --runner ips --rbenv '2.4.3;2.5.0'
266
282
  Calculating -------------------------------------
267
283
  2.4.3 2.5.0
268
284
  empty 228.802M 180.125M i/s - 20.000M times in 0.087412s 0.111034s
@@ -281,7 +297,7 @@ Comparison:
281
297
  ### time
282
298
 
283
299
  ```
284
- $ benchmark-driver examples/yaml/blank_loop.yml --runner time --rbenv '2.4.3;2.5.0'
300
+ $ benchmark-driver blank_loop.yml --runner time --rbenv '2.4.3;2.5.0'
285
301
  Calculating -------------------------------------
286
302
  2.4.3 2.5.0
287
303
  empty 0.087 0.110 s - 20.000M times
@@ -300,7 +316,7 @@ Comparison:
300
316
  ### memory
301
317
 
302
318
  ```
303
- $ benchmark-driver examples/yaml/blank_loop.yml --runner memory --rbenv '2.4.3;2.5.0'
319
+ $ benchmark-driver blank_loop.yml --runner memory --rbenv '2.4.3;2.5.0'
304
320
  Calculating -------------------------------------
305
321
  2.4.3 2.5.0
306
322
  empty 9.192M 9.364M bytes - 20.000M times
@@ -321,7 +337,7 @@ Comparison:
321
337
  Only for testing purpose.
322
338
 
323
339
  ```
324
- $ benchmark-driver examples/yaml/blank_loop.yml --runner once --rbenv '2.4.3;2.5.0'
340
+ $ benchmark-driver blank_loop.yml --runner once --rbenv '2.4.3;2.5.0'
325
341
  Calculating -------------------------------------
326
342
  2.4.3 2.5.0
327
343
  empty 1.818M 2.681M i/s - 1.000 times in 0.000001s 0.000000s
data/Rakefile CHANGED
@@ -1,52 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'shellwords'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- task :test do
5
- blank_loop = File.expand_path('./examples/yaml/blank_loop.yml', __dir__) # no warmup
6
- blank_hash = File.expand_path('./examples/yaml/blank_hash.yml', __dir__) # needs warmup
7
- {
8
- 'ips' => 'compare',
9
- 'time' => 'simple',
10
- 'memory' => 'simple',
11
- 'once' => 'markdown',
12
- }.each do |runner, output|
13
- Bundler.with_clean_env do
14
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', blank_loop, '-r', runner, '-o', output].shelljoin
15
- puts
16
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', blank_hash, '-r', runner, '-o', output, '--run-duration', '1'].shelljoin
17
- puts
18
- end
19
- end
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.ruby_opts = %w[-w]
6
+ t.rspec_opts = %w[--profile]
20
7
  end
21
8
 
22
- task :test_record do
23
- blank_loop = File.expand_path('./examples/yaml/blank_loop.yml', __dir__) # no warmup
24
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', blank_loop, '-r', 'ips', '-o', 'record'].shelljoin
25
- puts
26
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', 'benchmark_driver.record.yml', '-o', 'compare'].shelljoin
27
- puts
28
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', 'benchmark_driver.record.yml', '-o', 'record'].shelljoin
29
- puts
30
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', 'benchmark_driver.record.yml', '-o', 'simple'].shelljoin
31
- puts
32
- end
33
-
34
- task :test_ruby do
35
- Dir.glob(File.expand_path('./examples/*.rb', __dir__)).sort.each do |file|
36
- Bundler.with_clean_env do
37
- sh ['time', 'bundle', 'exec', 'ruby', file].shelljoin
38
- end
39
- puts
40
- end
41
- end
42
-
43
- task :test_yaml do
44
- Dir.glob(File.expand_path('./examples/yaml/*.yml', __dir__)).sort.each do |file|
45
- Bundler.with_clean_env do
46
- sh ['time', 'bundle', 'exec', 'exe/benchmark-driver', file, '--run-duration', '1'].shelljoin
47
- end
48
- puts
49
- end
50
- end
51
-
52
- task default: [:test, :test_record, :test_ruby, :test_yaml]
9
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mamaveb@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in benchmark-driver.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 bmarkons
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # benchmark-driver.gem
2
+
3
+ This is an alias to install `benchmark_driver.gem`.
4
+ It was built because its command name is actually `benchmark-driver`.
5
+
6
+ ## License
7
+
8
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "benchmark-driver"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["bmarkons"]
9
+ spec.email = ["mamaveb@gmail.com"]
10
+
11
+ spec.summary = %q{Alias gem to install benchmark_driver.gem}
12
+ spec.homepage = "https://github.com/benchmark-driver/benchmark-driver"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "benchmark_driver"
21
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "benchmark/driver"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ require 'benchmark_driver'
@@ -0,0 +1 @@
1
+ require 'benchmark_driver'
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'Fully-featured accurate benchmark driver for Ruby'
12
12
  spec.description = 'Fully-featured accurate benchmark driver for Ruby'
13
- spec.homepage = 'https://github.com/k0kubun/benchmark_driver'
13
+ spec.homepage = 'https://github.com/benchmark-driver/benchmark-driver'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rspec-retry'
26
28
  end
data/exe/benchmark-driver CHANGED
@@ -35,7 +35,7 @@ config = BenchmarkDriver::Config.new.tap do |c|
35
35
  executables << BenchmarkDriver::Rbenv.parse_spec(version)
36
36
  end
37
37
  end
38
- o.on('--repeat-count [NUM]', 'Try benchmark NUM times and use the fastest result (TODO)') do |v|
38
+ o.on('--repeat-count [NUM]', 'Try benchmark NUM times and use the fastest result or the worst memory usage') do |v|
39
39
  begin
40
40
  c.repeat_count = Integer(v)
41
41
  rescue ArgumentError
@@ -57,9 +57,9 @@ config = BenchmarkDriver::Config.new.tap do |c|
57
57
  end
58
58
  o.on('--run-duration [SECONDS]', 'Warmup estimates loop_count to run for this duration (default: 3)') do |v|
59
59
  begin
60
- c.run_duration = Integer(v)
60
+ c.run_duration = Float(v)
61
61
  rescue ArgumentError
62
- abort "--run-duration must take Integer, but got #{v.inspect}"
62
+ abort "--run-duration must take Float, but got #{v.inspect}"
63
63
  end
64
64
  end
65
65
  end
@@ -9,14 +9,14 @@ module BenchmarkDriver
9
9
  :executables, # @param [Array<BenchmarkDriver::Config::Executable>]
10
10
  :filters, # @param [Array<Regexp>]
11
11
  :repeat_count, # @param [Integer]
12
- :run_duration, # @param [Integer]
12
+ :run_duration, # @param [Float]
13
13
  :verbose, # @param [Integer]
14
14
  defaults: {
15
15
  runner_type: 'ips',
16
16
  output_type: 'compare',
17
17
  filters: [],
18
18
  repeat_count: 1,
19
- run_duration: 3,
19
+ run_duration: 3.0,
20
20
  verbose: 0,
21
21
  },
22
22
  )
@@ -25,7 +25,7 @@ module BenchmarkDriver
25
25
  Config::RunnerConfig = ::BenchmarkDriver::Struct.new(
26
26
  :executables, # @param [Array<BenchmarkDriver::Config::Executable>]
27
27
  :repeat_count, # @param [Integer]
28
- :run_duration, # @param [Integer]
28
+ :run_duration, # @param [Float]
29
29
  :verbose, # @param [Integer]
30
30
  )
31
31