benchmark_driver_monotonic_raw 0.14.13
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +357 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +386 -0
- data/Rakefile +9 -0
- data/benchmark-driver/.gitignore +12 -0
- data/benchmark-driver/CODE_OF_CONDUCT.md +74 -0
- data/benchmark-driver/Gemfile +6 -0
- data/benchmark-driver/LICENSE.txt +21 -0
- data/benchmark-driver/README.md +8 -0
- data/benchmark-driver/Rakefile +1 -0
- data/benchmark-driver/benchmark-driver.gemspec +21 -0
- data/benchmark-driver/bin/console +14 -0
- data/benchmark-driver/bin/setup +8 -0
- data/benchmark-driver/lib/benchmark-driver.rb +1 -0
- data/benchmark-driver/lib/benchmark/driver.rb +1 -0
- data/benchmark_driver.gemspec +28 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/exe/benchmark-driver +118 -0
- data/images/optcarrot.png +0 -0
- data/lib/benchmark_driver.rb +14 -0
- data/lib/benchmark_driver/bulk_output.rb +59 -0
- data/lib/benchmark_driver/config.rb +59 -0
- data/lib/benchmark_driver/default_job.rb +29 -0
- data/lib/benchmark_driver/default_job_parser.rb +91 -0
- data/lib/benchmark_driver/job_parser.rb +55 -0
- data/lib/benchmark_driver/metric.rb +79 -0
- data/lib/benchmark_driver/output.rb +88 -0
- data/lib/benchmark_driver/output/compare.rb +216 -0
- data/lib/benchmark_driver/output/markdown.rb +107 -0
- data/lib/benchmark_driver/output/record.rb +61 -0
- data/lib/benchmark_driver/output/simple.rb +103 -0
- data/lib/benchmark_driver/rbenv.rb +25 -0
- data/lib/benchmark_driver/repeater.rb +52 -0
- data/lib/benchmark_driver/ruby_interface.rb +83 -0
- data/lib/benchmark_driver/runner.rb +103 -0
- data/lib/benchmark_driver/runner/command_stdout.rb +118 -0
- data/lib/benchmark_driver/runner/ips.rb +259 -0
- data/lib/benchmark_driver/runner/memory.rb +150 -0
- data/lib/benchmark_driver/runner/once.rb +118 -0
- data/lib/benchmark_driver/runner/recorded.rb +73 -0
- data/lib/benchmark_driver/runner/ruby_stdout.rb +146 -0
- data/lib/benchmark_driver/runner/time.rb +20 -0
- data/lib/benchmark_driver/struct.rb +98 -0
- data/lib/benchmark_driver/version.rb +3 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9eae22208b3dcf261733524be5827dbdb4744ec2
|
4
|
+
data.tar.gz: b2cfbd1d7ec3c8f30cc782014057b4e302e2fe55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30288dc02ee36d5f7854874a6a2ddb010331c582b712bce6bcb806dcc219e30a5ff952851c629e8d795608e26fa3ff961915e551b660ae8c54f718349ac119a4
|
7
|
+
data.tar.gz: 0b638ec6fbfea4989002a7b94b865d0bdc2fff58f947f22f57c93a7aa505563859c84fa4a42f04bb896d17254d6e39fa6dbd2add51149e0e9d7731b00e08fa84
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper.rb
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2.8
|
4
|
+
- 2.3.6
|
5
|
+
- 2.4.3
|
6
|
+
- 2.5.0
|
7
|
+
cache: bundler
|
8
|
+
branches:
|
9
|
+
only:
|
10
|
+
- master
|
11
|
+
before_install:
|
12
|
+
- gem install bundler -v 1.15.4
|
13
|
+
- gem install haml -v 4.0.7
|
14
|
+
- gem install haml -v 5.0.4
|
15
|
+
script:
|
16
|
+
- RSPEC_RETRIES=3 VERBOSE=1 bundle exec rake
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
# v0.14.13
|
2
|
+
|
3
|
+
- Add macOS support to memory runner
|
4
|
+
[#53](https://github.com/benchmark-driver/benchmark-driver/pull/53)
|
5
|
+
|
6
|
+
# v0.14.12
|
7
|
+
|
8
|
+
- Reduce the risk of random ZeroDivisionError on warmup
|
9
|
+
[#52](https://github.com/benchmark-driver/benchmark-driver/pull/52)
|
10
|
+
|
11
|
+
# v0.14.11
|
12
|
+
|
13
|
+
- Add `x.executable` method to Ruby interface for specifying Ruby executable which is not managed by rbenv
|
14
|
+
[#50](https://github.com/benchmark-driver/benchmark-driver/pull/50)
|
15
|
+
|
16
|
+
# v0.14.10
|
17
|
+
|
18
|
+
- Resolve internal Ruby warnings
|
19
|
+
|
20
|
+
# v0.14.9
|
21
|
+
|
22
|
+
- Allow recorded runner to run without the recorded Ruby executables
|
23
|
+
[#43](https://github.com/benchmark-driver/benchmark-driver/issues/43) [#44](https://github.com/benchmark-driver/benchmark-driver/issues/44)
|
24
|
+
|
25
|
+
# v0.14.8
|
26
|
+
|
27
|
+
- Fix bug that "benchmark\_driver.record.yml" created with `-e`/`--rbenv` option
|
28
|
+
has required to specify the same `-e`/`--rbenv` option [#42](https://github.com/benchmark-driver/benchmark-driver/issues/42)
|
29
|
+
|
30
|
+
# v0.14.7
|
31
|
+
|
32
|
+
- Fix bug on warmup with `BenchmarkDriver::BulkOutput` [#40](https://github.com/benchmark-driver/benchmark-driver/issues/40)
|
33
|
+
- This is currently used by benchmark\_driver-output-gruff
|
34
|
+
|
35
|
+
# v0.14.6
|
36
|
+
|
37
|
+
- Improve option parser validation
|
38
|
+
- Add `--timeout` option only for Linux having timeout(1)
|
39
|
+
- Support `--version` option
|
40
|
+
- Fix help output for `-e`/`--rbenv` in benchmark-driver command
|
41
|
+
|
42
|
+
# v0.14.5
|
43
|
+
|
44
|
+
- Fix wrong spacing format in simple / markdown output
|
45
|
+
|
46
|
+
# v0.14.4
|
47
|
+
|
48
|
+
- Fix runners and outputs to distinguish 0.0 and ERROR value
|
49
|
+
|
50
|
+
# v0.14.3
|
51
|
+
|
52
|
+
- Support loading runner plugin
|
53
|
+
|
54
|
+
# v0.14.2
|
55
|
+
|
56
|
+
- Fix definitive error in v0.14.1...
|
57
|
+
|
58
|
+
# v0.14.1 (yanked)
|
59
|
+
|
60
|
+
- Fix `BenchmarkDriver::BulkOutput` error on contexts with prelude [#38](https://github.com/benchmark-driver/benchmark-driver/issues/38)
|
61
|
+
|
62
|
+
# v0.14.0
|
63
|
+
|
64
|
+
- `benchmark-driver` command also takes `*.rb` file to run single-execution benchmark
|
65
|
+
- Non-`*.rb` filename is considered as YAML file as before
|
66
|
+
- [breaking change] `--verbose` no longer takes LEVEL argument
|
67
|
+
- Added `-v` for `-v`/`-vv` instead of `--verbose 1` and `--verbose 2`.
|
68
|
+
- `--verbose --verbose` can also be used instead of `--verbose 2` if you want.
|
69
|
+
- [breaking change] Use ` `(space) to split Ruby arguments in `-e`/`--executables`/`--rbenv`
|
70
|
+
- ex) `-e "/path/to/ruby --jit"` should be used instead of `-e "/path/to/ruby,--jit"`
|
71
|
+
- [experimental] Return 0.0 as value when benchmark script fails on ips/time/memory/once runners
|
72
|
+
- Exit status is 0 for that case. `benchmark-driver` exits abnormaly only on its internal bug.
|
73
|
+
|
74
|
+
# v0.13.3
|
75
|
+
|
76
|
+
- Support `require: false` in contexts to skip automatic requirement with a gem name
|
77
|
+
|
78
|
+
# v0.13.2
|
79
|
+
|
80
|
+
- Stop generating loop code with `loop_count: 1` on ips runner
|
81
|
+
|
82
|
+
# v0.13.1
|
83
|
+
|
84
|
+
- Respect a magic comment in `prelude`
|
85
|
+
|
86
|
+
# v0.13.0
|
87
|
+
|
88
|
+
- Add support for benchmark with different versions of gems and preludes
|
89
|
+
- Only YAML is supported for now, Ruby interface will come later
|
90
|
+
- [breaking change] Runner plugin interface is slightly changed
|
91
|
+
|
92
|
+
# v0.12.0
|
93
|
+
|
94
|
+
- [breaking change] Plugin interface is changed again
|
95
|
+
- Fix bugs in a case that multiple YAMLs with different types are specified
|
96
|
+
- Output plugin is now ensured to yield the same metrics
|
97
|
+
|
98
|
+
# v0.11.1
|
99
|
+
|
100
|
+
- Add `--repeat-result` option to return the best, the worst or an average result with `--repeat-count`
|
101
|
+
- Add `BenchmarkDriver::BulkOutput` to make an output plugin casually
|
102
|
+
|
103
|
+
# v0.11.0
|
104
|
+
|
105
|
+
- [breaking change] Plugin interface is completely changed, so all plugins need migration
|
106
|
+
- YAML/Ruby interface is not changed at all
|
107
|
+
- Now the internal model allows to have multiple metrics in the same job,
|
108
|
+
but having multiple metrics is still not respected by built-in plugins
|
109
|
+
- "executable" is renamed to be "context", but still configuring a context
|
110
|
+
other than an executable is not supported yet
|
111
|
+
- A metric can have a name
|
112
|
+
- Add `ruby_stdout` runner
|
113
|
+
- This can parse an arbitrary "environment" for the "context"
|
114
|
+
- Metric can have name
|
115
|
+
- Metric name is shwon on some outputs like markdown and simple
|
116
|
+
- `--run-duration` accepts floating-point number
|
117
|
+
- News: Now benchmark-driver.gem can be used as an alias to install benchmark\_driver.gem
|
118
|
+
|
119
|
+
# v0.10.16
|
120
|
+
|
121
|
+
- `command_stdout` runner uses YAML's dirname as `working_directory` by default
|
122
|
+
|
123
|
+
# v0.10.15
|
124
|
+
|
125
|
+
- Make `Benchmark.driver` take `repeat_count:` keyword argument
|
126
|
+
|
127
|
+
# v0.10.14
|
128
|
+
|
129
|
+
- Fix a bug that large time is shown as better in time runner
|
130
|
+
|
131
|
+
# v0.10.13
|
132
|
+
|
133
|
+
- Add `x.output` to specify output plugin to Ruby interface
|
134
|
+
- You can still use `Benchmark.driver(output: xxx)` form too
|
135
|
+
|
136
|
+
# v0.10.12
|
137
|
+
|
138
|
+
- Fix some typo in help
|
139
|
+
- Add dynamic require for convenience to implement output plugins
|
140
|
+
|
141
|
+
# v0.10.11
|
142
|
+
|
143
|
+
- Add `:required_ruby_option` parameter in YAML format
|
144
|
+
|
145
|
+
# v0.10.10
|
146
|
+
|
147
|
+
- Add `BenchmarkDriver::Config::Executable#description` method to return `ruby -v` result for output plugins.
|
148
|
+
|
149
|
+
# v0.10.9
|
150
|
+
|
151
|
+
- Add `x.rbenv`, `x.loop_count`, `x.verbose` supports to Ruby interface
|
152
|
+
|
153
|
+
# v0.10.8
|
154
|
+
|
155
|
+
- In `command_stdout`, `$RBENV_VERSION` is no longer passed to --rbenv option because it has no effect for rbenv
|
156
|
+
- Instead, now dirname of executable path is prefixed to $PATH in `command_stdout`
|
157
|
+
|
158
|
+
# v0.10.7
|
159
|
+
|
160
|
+
- Pass `$RBENV_VERSION` for `command_stdout` runner with --rbenv option
|
161
|
+
|
162
|
+
# v0.10.6
|
163
|
+
|
164
|
+
- Fix TypeError on Ruby <= 2.3
|
165
|
+
|
166
|
+
# v0.10.5
|
167
|
+
|
168
|
+
- Run runners with Bundler's clean env
|
169
|
+
|
170
|
+
# v0.10.4
|
171
|
+
|
172
|
+
- Fix frozen string error when parsing multiple jobs
|
173
|
+
|
174
|
+
# v0.10.3
|
175
|
+
|
176
|
+
- Allow specifying name in `--rbenv`
|
177
|
+
- Don't print stderr in "command\_stdout" runner
|
178
|
+
|
179
|
+
# v0.10.2
|
180
|
+
|
181
|
+
- Optionalize `working_directory` of "command\_stdout" runner
|
182
|
+
|
183
|
+
# v0.10.1
|
184
|
+
|
185
|
+
- Add "command\_stdout" runner to plug in existing benchmark
|
186
|
+
- Explicitly bump supported Ruby version to >= 2.2
|
187
|
+
- v0.10.0 actually does not work with 2.1
|
188
|
+
- You can still benchmark Ruby 2.0, 2.1 by --executable, but you need to use newer Ruby for driver
|
189
|
+
|
190
|
+
# v0.10.0
|
191
|
+
|
192
|
+
- Add "record" output and "recorded" runner
|
193
|
+
- You can record metrics to yaml and change how to output later
|
194
|
+
- Change output interface to set metrics\_type
|
195
|
+
- Now runner needs to call `output#metrics_type=`
|
196
|
+
|
197
|
+
# v0.9.2
|
198
|
+
|
199
|
+
- Add `--verbose` option
|
200
|
+
- `--verbose 1` shows `ruby -v` for each executable
|
201
|
+
- `--verbose 2` shows executed scripts
|
202
|
+
|
203
|
+
# v0.9.1
|
204
|
+
|
205
|
+
- Fix memory runner bug that actually doesn't run the benchmarked script
|
206
|
+
- Add once runner to test benchmark script in a short time
|
207
|
+
|
208
|
+
# v0.9.0
|
209
|
+
|
210
|
+
- The concept of runner is renewed
|
211
|
+
- Now it's for specifying metrics like ips, time, memory usage
|
212
|
+
- Old runners (:call and :eval) are no longer supported. :exec only.
|
213
|
+
- So Ruby interface can't take Proc
|
214
|
+
- YAML can have arbitrary format depending on the runner
|
215
|
+
- `--compare` option is dropped and changed to `--output compare`
|
216
|
+
- `--dir` option is dropped for now
|
217
|
+
|
218
|
+
# v0.8.6
|
219
|
+
|
220
|
+
- Automatically require `benchmark/output/foo` when `-o foo` is specified
|
221
|
+
|
222
|
+
# v0.8.5
|
223
|
+
|
224
|
+
- Show time per iteration for ips output
|
225
|
+
- Show clocks/i too when it's < 1000 clocks/i
|
226
|
+
- In ips output, 'B' unit (10^9) is changed to 'G'
|
227
|
+
|
228
|
+
# v0.8.4
|
229
|
+
|
230
|
+
- Add `loop_count` option to Ruby interface
|
231
|
+
|
232
|
+
# v0.8.3
|
233
|
+
|
234
|
+
- Make benchmark\_driver runnable when Bundler is not installed
|
235
|
+
|
236
|
+
# v0.8.2
|
237
|
+
|
238
|
+
- Fix bug on showing error message in `benchmark-driver` command
|
239
|
+
|
240
|
+
# v0.8.1
|
241
|
+
|
242
|
+
- Fix internal implementation of Eval runner
|
243
|
+
- Now this can accept class definition in prelude
|
244
|
+
|
245
|
+
# v0.8.0
|
246
|
+
|
247
|
+
- Force using :exec runner for YAML interface
|
248
|
+
- Fix bug that executables become empty
|
249
|
+
|
250
|
+
# v0.7.2
|
251
|
+
|
252
|
+
- Respect ignored output option in Ruby interface
|
253
|
+
|
254
|
+
# v0.7.1
|
255
|
+
|
256
|
+
- Add `x.rbenv` to Ruby interface
|
257
|
+
- Add `x.bundler` to Ruby interface
|
258
|
+
|
259
|
+
# v0.7.0
|
260
|
+
|
261
|
+
- Change Ruby interface for specifying prelude and script
|
262
|
+
- #prelude= is renamed to #prelude
|
263
|
+
- `script:` is no longer a keyword argument
|
264
|
+
- Add Eval runner and it's made default for Ruby interface when script is String
|
265
|
+
|
266
|
+
# v0.6.2
|
267
|
+
|
268
|
+
- Resurrect support of Ruby interface dropped at v0.6.0
|
269
|
+
- Invalidate wrong configuration
|
270
|
+
- Decide runner type automatically for Ruby interface
|
271
|
+
|
272
|
+
# v0.6.1
|
273
|
+
|
274
|
+
- Support markdown output
|
275
|
+
|
276
|
+
# v0.6.0
|
277
|
+
|
278
|
+
- Drop support of Ruby interface
|
279
|
+
- Drop support of specifying runner, output options on YAML definition
|
280
|
+
- Allow specifying output type on CLI
|
281
|
+
- Run multiple benchmark files at once, instead of sequentially executing them
|
282
|
+
|
283
|
+
# v0.5.1
|
284
|
+
|
285
|
+
- Fix a bug that fails to run multiple Ruby binaries when multiple YAML files are specified
|
286
|
+
|
287
|
+
# v0.5.0
|
288
|
+
|
289
|
+
- Automatic bundle install for each Ruby executable on `--bundler` or `--bundle`
|
290
|
+
- CLI error handling is improved for empty/invalid arguments
|
291
|
+
|
292
|
+
# v0.4.5
|
293
|
+
|
294
|
+
- Allow specifying arguments for ruby executables
|
295
|
+
|
296
|
+
# v0.4.4
|
297
|
+
|
298
|
+
- Add `--bundler` option to run benchmark with fixed gems
|
299
|
+
|
300
|
+
# v0.4.3
|
301
|
+
|
302
|
+
- Add `--filter` option to run only specified benchmarks
|
303
|
+
|
304
|
+
# v0.4.2
|
305
|
+
|
306
|
+
- Exec runner uses `Bundler.with_clean_env`
|
307
|
+
|
308
|
+
# v0.4.1
|
309
|
+
|
310
|
+
- Increase the number of pasted script in one loop: 50 -> 1000
|
311
|
+
- Add `--dir` option to override `__dir__`
|
312
|
+
|
313
|
+
# v0.4.0
|
314
|
+
|
315
|
+
- **Full scratch**: v0.1...v0.3 has no relationship with v0.4
|
316
|
+
- Plugin support for runner, output
|
317
|
+
- Add initial limited Ruby interface in addition to previous YAML input
|
318
|
+
- Add new `call` runner for Ruby and `exec` runner for existing functionality
|
319
|
+
- Support repeating multiple times and using the best result
|
320
|
+
- Add `compare!` switching
|
321
|
+
- Gradual loop time estimation for specific duration
|
322
|
+
- Real-time incremental output during benchmark execution
|
323
|
+
- Paste the same script 50 times in one loop
|
324
|
+
|
325
|
+
# v0.3.0
|
326
|
+
|
327
|
+
- Rename `benchmark_driver` command to `benchmark-driver`
|
328
|
+
- Internally use `Benchmark::Driver` namespace instead of `BenchmarkDriver`
|
329
|
+
|
330
|
+
# v0.2.4
|
331
|
+
|
332
|
+
- Allow specifying multiple rbenv executables at once
|
333
|
+
|
334
|
+
# v0.2.3
|
335
|
+
|
336
|
+
- Add `--rbenv` option to specify executables in rbenv
|
337
|
+
|
338
|
+
# v0.2.2
|
339
|
+
|
340
|
+
- Fix loop count option bug
|
341
|
+
|
342
|
+
# v0.2.1
|
343
|
+
|
344
|
+
- Stop using `i` for wrapper script for loop
|
345
|
+
- Fix IPS option bug by @t8m8
|
346
|
+
|
347
|
+
# v0.2.0
|
348
|
+
|
349
|
+
- Allow specifying loop count
|
350
|
+
|
351
|
+
# v0.1.0
|
352
|
+
|
353
|
+
- Add `benchmark_driver` command that takes YAML input
|
354
|
+
- Runnable with multiple Ruby binaries
|
355
|
+
- Show actual time
|
356
|
+
- IPS reporter support
|
357
|
+
- Prelude and multiple benchmark scripts in one YAML
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Takashi Kokubun
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,386 @@
|
|
1
|
+
# BenchmarkDriver [](https://travis-ci.org/benchmark-driver/benchmark-driver)
|
2
|
+
|
3
|
+
Fully-featured accurate benchmark driver for Ruby
|
4
|
+
|
5
|
+
## Features
|
6
|
+
### Accurate Measurement
|
7
|
+
|
8
|
+
- Low overhead benchmark by running generated script instead of calling Proc
|
9
|
+
- Profiling memory and high-precision real time
|
10
|
+
- Running multiple times to minimize measurement errors
|
11
|
+
|
12
|
+
### Pluggable & Fully Featured
|
13
|
+
|
14
|
+
- Flexible and real-time output format in comparison, markdown table, graph, etc.
|
15
|
+
- Measuring various metrics by specifying runners
|
16
|
+
- Integrated benchmark support using external libraries
|
17
|
+
- Runner and output format are all pluggable
|
18
|
+
|
19
|
+
### Flexible Interface
|
20
|
+
|
21
|
+
- Ruby interface similar to stdlib benchmark.rb, benchmark-ips
|
22
|
+
- YAML input to easily manage structured benchmark set
|
23
|
+
- Comparing multiple Ruby binaries, even with miniruby
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
```
|
28
|
+
$ gem install benchmark_driver
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
### Ruby Interface
|
34
|
+
|
35
|
+
This interface generates code to profile with low overhead and executes it.
|
36
|
+
|
37
|
+
```rb
|
38
|
+
require 'benchmark_driver'
|
39
|
+
|
40
|
+
Benchmark.driver do |x|
|
41
|
+
x.prelude <<~RUBY
|
42
|
+
require 'active_support/all'
|
43
|
+
array = []
|
44
|
+
RUBY
|
45
|
+
|
46
|
+
x.report 'blank?', %{ array.blank? }
|
47
|
+
x.report 'empty?', %{ array.empty? }
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
or simply:
|
52
|
+
|
53
|
+
```rb
|
54
|
+
require 'benchmark_driver'
|
55
|
+
|
56
|
+
Benchmark.driver do |x|
|
57
|
+
x.prelude <<~RUBY
|
58
|
+
require 'active_support/all'
|
59
|
+
array = []
|
60
|
+
RUBY
|
61
|
+
|
62
|
+
x.report %{ array.blank? }
|
63
|
+
x.report %{ array.empty? }
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
### Structured YAML Input
|
68
|
+
|
69
|
+
With `benchmark-driver` command, you can describe benchmark with YAML input.
|
70
|
+
|
71
|
+
```
|
72
|
+
$ benchmark-driver -h
|
73
|
+
Usage: benchmark-driver [options] [YAML|RUBY]
|
74
|
+
-r, --runner [TYPE] Specify runner type: ips, time, memory, once (default: ips)
|
75
|
+
-o, --output [TYPE] Specify output type: compare, simple, markdown, record (default: compare)
|
76
|
+
-e, --executables [EXECS] Ruby executables (e1::path1 arg1; e2::path2 arg2;...)
|
77
|
+
--rbenv [VERSIONS] Ruby executables in rbenv (x.x.x arg1;y.y.y arg2;...)
|
78
|
+
--repeat-count [NUM] Try benchmark NUM times and use the fastest result or the worst memory usage
|
79
|
+
--repeat-result [TYPE] Yield "best", "average" or "worst" result with --repeat-count (default: best)
|
80
|
+
--bundler Install and use gems specified in Gemfile
|
81
|
+
--filter [REGEXP] Filter out benchmarks with given regexp
|
82
|
+
--run-duration [SECONDS] Warmup estimates loop_count to run for this duration (default: 3)
|
83
|
+
-v, --verbose Verbose mode. Multiple -v options increase visilibity (max: 2)
|
84
|
+
```
|
85
|
+
|
86
|
+
#### Running single script
|
87
|
+
|
88
|
+
With following `example_single.yml`,
|
89
|
+
|
90
|
+
```yml
|
91
|
+
prelude: |
|
92
|
+
require 'erb'
|
93
|
+
erb = ERB.new(%q[Hello <%= 'World' %>])
|
94
|
+
benchmark: erb.result
|
95
|
+
```
|
96
|
+
|
97
|
+
you can benchmark the script with multiple ruby executables.
|
98
|
+
|
99
|
+
```
|
100
|
+
$ benchmark-driver example_single.yml --rbenv '2.4.1;2.5.0'
|
101
|
+
Warming up --------------------------------------
|
102
|
+
erb.result 71.683k i/s
|
103
|
+
Calculating -------------------------------------
|
104
|
+
2.4.1 2.5.0
|
105
|
+
erb.result 72.387k 75.046k i/s - 215.049k times in 2.970833s 2.865581s
|
106
|
+
|
107
|
+
Comparison:
|
108
|
+
erb.result
|
109
|
+
2.5.0: 75045.5 i/s
|
110
|
+
2.4.1: 72386.8 i/s - 1.04x slower
|
111
|
+
```
|
112
|
+
|
113
|
+
#### Running multiple scripts
|
114
|
+
|
115
|
+
One YAML file can contain multiple benchmark scripts.
|
116
|
+
With following `example_multi.yml`,
|
117
|
+
|
118
|
+
```yml
|
119
|
+
prelude: |
|
120
|
+
a = 'a' * 100
|
121
|
+
b = 'b' * 100
|
122
|
+
benchmark:
|
123
|
+
join: '[a, b].join'
|
124
|
+
str-interp: '"#{a}#{b}"'
|
125
|
+
```
|
126
|
+
|
127
|
+
you can benchmark the scripts with multiple ruby executables.
|
128
|
+
|
129
|
+
```
|
130
|
+
$ benchmark-driver example_multi.yml --rbenv '2.4.1;2.5.0'
|
131
|
+
Warming up --------------------------------------
|
132
|
+
join 2.509M i/s
|
133
|
+
str-interp 1.772M i/s
|
134
|
+
Calculating -------------------------------------
|
135
|
+
2.4.1 2.5.0
|
136
|
+
join 2.661M 2.863M i/s - 7.527M times in 2.828771s 2.629191s
|
137
|
+
str-interp 1.890M 3.258M i/s - 5.315M times in 2.812240s 1.630997s
|
138
|
+
|
139
|
+
Comparison:
|
140
|
+
join
|
141
|
+
2.5.0: 2862755.1 i/s
|
142
|
+
2.4.1: 2660777.4 i/s - 1.08x slower
|
143
|
+
|
144
|
+
str-interp
|
145
|
+
2.5.0: 3258489.7 i/s
|
146
|
+
2.4.1: 1889805.6 i/s - 1.72x slower
|
147
|
+
```
|
148
|
+
|
149
|
+
## Output Options
|
150
|
+
|
151
|
+
By default, there are following output options.
|
152
|
+
|
153
|
+
| Output | Description |
|
154
|
+
|:-------|:------------|
|
155
|
+
| compare | benchmark-ips's `compare!`-like output (default) |
|
156
|
+
| simple | ruby's original `benchmark/driver.rb`-like simple output |
|
157
|
+
| markdown | output in markdown table |
|
158
|
+
| record | serialize results in `benchmark_driver.record.yml`, to change outputs later as you like |
|
159
|
+
|
160
|
+
With `benchmark-driver` CLI, you can specify it with `-o [output]` or `--output [output]`.
|
161
|
+
|
162
|
+
With Ruby interface, you can specify it like:
|
163
|
+
|
164
|
+
```rb
|
165
|
+
Benchmark.driver do |x|
|
166
|
+
x.prelude %{ array = [] }
|
167
|
+
x.report 'Array#empty?', %{ array.empty? }
|
168
|
+
x.output 'markdown'
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
With following `blank_loop.yml`,
|
173
|
+
|
174
|
+
```yml
|
175
|
+
loop_count: 20000000
|
176
|
+
prelude: |
|
177
|
+
class Array
|
178
|
+
alias_method :blank?, :empty?
|
179
|
+
end
|
180
|
+
array = []
|
181
|
+
benchmark:
|
182
|
+
empty: array.empty?
|
183
|
+
blank: array.blank?
|
184
|
+
```
|
185
|
+
|
186
|
+
you can output results in various ways like:
|
187
|
+
|
188
|
+
### compare
|
189
|
+
|
190
|
+
```
|
191
|
+
$ benchmark-driver blank_loop.yml --output compare --rbenv '2.4.2;2.5.0'
|
192
|
+
Calculating -------------------------------------
|
193
|
+
2.4.2 2.5.0
|
194
|
+
empty 195.957M 129.970M i/s - 20.000M times in 0.102063s 0.153882s
|
195
|
+
blank 66.554M 55.630M i/s - 20.000M times in 0.300507s 0.359519s
|
196
|
+
|
197
|
+
Comparison:
|
198
|
+
empty
|
199
|
+
2.4.2: 195957398.5 i/s
|
200
|
+
2.5.0: 129969716.9 i/s - 1.51x slower
|
201
|
+
|
202
|
+
blank
|
203
|
+
2.4.2: 66554190.0 i/s
|
204
|
+
2.5.0: 55629883.2 i/s - 1.20x slower
|
205
|
+
```
|
206
|
+
|
207
|
+
### simple
|
208
|
+
|
209
|
+
```
|
210
|
+
$ benchmark-driver blank_loop.yml --output simple --rbenv '2.4.2;2.5.0'
|
211
|
+
benchmark results (i/s):
|
212
|
+
2.4.2 2.5.0
|
213
|
+
empty 184.084M 117.319M
|
214
|
+
blank 65.843M 62.093M
|
215
|
+
```
|
216
|
+
|
217
|
+
### markdown
|
218
|
+
|
219
|
+
```
|
220
|
+
$ benchmark-driver blank_loop.yml --output markdown --rbenv '2.4.2;2.5.0'
|
221
|
+
```
|
222
|
+
|
223
|
+
benchmark results (i/s)
|
224
|
+
|
225
|
+
| | 2.4.2| 2.5.0|
|
226
|
+
|:------|:-------|:-------|
|
227
|
+
|empty |187.296M|117.662M|
|
228
|
+
|blank | 58.895M| 58.852M|
|
229
|
+
|
230
|
+
### record
|
231
|
+
|
232
|
+
Measure first, output with various formats later.
|
233
|
+
|
234
|
+
```
|
235
|
+
$ benchmark-driver blank_loop.yml --output record --rbenv '2.4.2;2.5.0'
|
236
|
+
benchmarking....
|
237
|
+
|
238
|
+
$ benchmark-driver benchmark_driver.record.yml --output compare
|
239
|
+
Calculating -------------------------------------
|
240
|
+
empty 153.380M 114.228M i/s - 20.000M times in 0.130395s 0.175088s
|
241
|
+
blank 67.834M 64.328M i/s - 20.000M times in 0.294836s 0.310906s
|
242
|
+
|
243
|
+
Comparison:
|
244
|
+
empty: 153380113.9 i/s
|
245
|
+
blank: 67834321.4 i/s - 2.26x slower
|
246
|
+
|
247
|
+
$ benchmark-driver benchmark_driver.record.yml --output simple
|
248
|
+
benchmark results (i/s):
|
249
|
+
empty 153.380M 114.228M
|
250
|
+
blank 67.834M 64.328M
|
251
|
+
```
|
252
|
+
|
253
|
+
### gruff
|
254
|
+
|
255
|
+
There is [benchmark\_driver-output-gruff](https://github.com/benchmark-driver/benchmark_driver-output-gruff)
|
256
|
+
plugin that renders a graph using gruff.gem.
|
257
|
+
|
258
|
+

|
259
|
+
|
260
|
+
### benchmark-driver.github.io
|
261
|
+
|
262
|
+
Benchmark results for https://benchmark-driver.github.io are also stored by [output plugin](https://github.com/benchmark-driver/skybench/tree/master/plugins/benchmark_driver-output-skybench).
|
263
|
+
You can integrate any system as you like.
|
264
|
+
|
265
|
+
## Runner Options
|
266
|
+
|
267
|
+
Runner decides metrics to be collected. There are following default runner options.
|
268
|
+
|
269
|
+
ips, time, memory, once
|
270
|
+
|
271
|
+
| Runner | Description |
|
272
|
+
|:-------|:------------|
|
273
|
+
| ips | Iteration per second (default) |
|
274
|
+
| time | Elapsed seconds |
|
275
|
+
| memory | Max resident set. This is supported only on Linux and macOS for now. |
|
276
|
+
| once | Forces `loop_count` to 1 for testing |
|
277
|
+
| ruby\_stdout | Special runner to integrate existing benchmarks |
|
278
|
+
|
279
|
+
### ips
|
280
|
+
|
281
|
+
```
|
282
|
+
$ benchmark-driver blank_loop.yml --runner ips --rbenv '2.4.3;2.5.0'
|
283
|
+
Calculating -------------------------------------
|
284
|
+
2.4.3 2.5.0
|
285
|
+
empty 228.802M 180.125M i/s - 20.000M times in 0.087412s 0.111034s
|
286
|
+
blank 90.012M 88.853M i/s - 20.000M times in 0.222193s 0.225090s
|
287
|
+
|
288
|
+
Comparison:
|
289
|
+
empty
|
290
|
+
2.4.3: 228801720.5 i/s
|
291
|
+
2.5.0: 180124821.8 i/s - 1.27x slower
|
292
|
+
|
293
|
+
blank
|
294
|
+
2.4.3: 90012021.7 i/s
|
295
|
+
2.5.0: 88853269.4 i/s - 1.01x slower
|
296
|
+
```
|
297
|
+
|
298
|
+
### time
|
299
|
+
|
300
|
+
```
|
301
|
+
$ benchmark-driver blank_loop.yml --runner time --rbenv '2.4.3;2.5.0'
|
302
|
+
Calculating -------------------------------------
|
303
|
+
2.4.3 2.5.0
|
304
|
+
empty 0.087 0.110 s - 20.000M times
|
305
|
+
blank 0.217 0.219 s - 20.000M times
|
306
|
+
|
307
|
+
Comparison:
|
308
|
+
empty
|
309
|
+
2.5.0: 0.1 s
|
310
|
+
2.4.3: 0.1 s - 1.26x slower
|
311
|
+
|
312
|
+
blank
|
313
|
+
2.5.0: 0.2 s
|
314
|
+
2.4.3: 0.2 s - 1.01x slower
|
315
|
+
```
|
316
|
+
|
317
|
+
### memory
|
318
|
+
|
319
|
+
```
|
320
|
+
$ benchmark-driver blank_loop.yml --runner memory --rbenv '2.4.3;2.5.0'
|
321
|
+
Calculating -------------------------------------
|
322
|
+
2.4.3 2.5.0
|
323
|
+
empty 9.192M 9.364M bytes - 20.000M times
|
324
|
+
blank 9.080M 9.372M bytes - 20.000M times
|
325
|
+
|
326
|
+
Comparison:
|
327
|
+
empty
|
328
|
+
2.4.3: 9192000.0 bytes
|
329
|
+
2.5.0: 9364000.0 bytes - 1.02x larger
|
330
|
+
|
331
|
+
blank
|
332
|
+
2.4.3: 9080000.0 bytes
|
333
|
+
2.5.0: 9372000.0 bytes - 1.03x larger
|
334
|
+
```
|
335
|
+
|
336
|
+
### once
|
337
|
+
|
338
|
+
Only for testing purpose.
|
339
|
+
|
340
|
+
```
|
341
|
+
$ benchmark-driver blank_loop.yml --runner once --rbenv '2.4.3;2.5.0'
|
342
|
+
Calculating -------------------------------------
|
343
|
+
2.4.3 2.5.0
|
344
|
+
empty 1.818M 2.681M i/s - 1.000 times in 0.000001s 0.000000s
|
345
|
+
blank 1.531M 2.421M i/s - 1.000 times in 0.000001s 0.000000s
|
346
|
+
|
347
|
+
Comparison:
|
348
|
+
empty
|
349
|
+
2.5.0: 2680965.1 i/s
|
350
|
+
2.4.3: 1818181.8 i/s - 1.47x slower
|
351
|
+
|
352
|
+
blank
|
353
|
+
2.5.0: 2421307.5 i/s
|
354
|
+
2.4.3: 1531393.6 i/s - 1.58x slower
|
355
|
+
```
|
356
|
+
|
357
|
+
### ruby\_stdout
|
358
|
+
|
359
|
+
See following example:
|
360
|
+
|
361
|
+
* https://github.com/benchmark-driver/optcarrot
|
362
|
+
|
363
|
+
If your benchmark can run with `ruby foo bar`, specify `foo bar` to `command:`.
|
364
|
+
Then write `stdout_to_metrics:` to convert stdout to metrics. This runner can be used only with YAML interface for now.
|
365
|
+
|
366
|
+
```
|
367
|
+
$ benchmark-driver benchmark.yml --verbose 1 --rbenv '2.6.0-dev;2.6.0-dev --jit'
|
368
|
+
2.6.0-dev: ruby 2.6.0dev (2018-03-21 trunk 62870) [x86_64-linux]
|
369
|
+
2.6.0-dev --jit: ruby 2.6.0dev (2018-03-21 trunk 62870) +JIT [x86_64-linux]
|
370
|
+
Calculating -------------------------------------
|
371
|
+
2.6.0-dev 2.6.0-dev --jit
|
372
|
+
optcarrot 51.866 67.445 fps
|
373
|
+
|
374
|
+
Comparison:
|
375
|
+
optcarrot
|
376
|
+
2.6.0-dev --jit: 67.4 fps
|
377
|
+
2.6.0-dev: 51.9 fps - 1.30x slower
|
378
|
+
```
|
379
|
+
|
380
|
+
## Contributing
|
381
|
+
|
382
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/benchmark-driver/benchmark-driver.
|
383
|
+
|
384
|
+
## License
|
385
|
+
|
386
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|