benchable 0.3.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +9 -2
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/lib/benchable/benchmark.rb +12 -10
- data/lib/benchable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53c01c57feaf90f0e66348f0c9616fb0d7b14ef6c113275994b3c7d73904f6e9
|
4
|
+
data.tar.gz: f29e837f82bcc9249759def201b971945f7d9eff2137effc36f0401a01180184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8fd398efe20aa3d49066d7a49dffc5db82c8a31a2aac961a117f37d472ed3a2c2db80a1b227633ff6344e4c0af5ee657bce8cf83b0199507b0af1cddadd1941
|
7
|
+
data.tar.gz: 2f88177d45d8ec82b0732b0b32c2156a6d24a7fc8a1bdd30402e8afe4a61d4618982fea4e6e8a7bff7b3175bde53bfe89d2a0c081f09bb151012648c2eb38966
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
8
8
|
## [Unreleased]
|
9
9
|
---
|
10
10
|
|
11
|
+
## [0.3.1] - 2021-09-10
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Fix benchmark arguments for Benchmark::Memory.
|
16
|
+
|
11
17
|
## [0.3.0] - 2021-09-09
|
12
18
|
|
13
19
|
### Added
|
@@ -52,7 +58,8 @@ end
|
|
52
58
|
### Added
|
53
59
|
- Support for `Benchmark.bm`, `Benchmark.bmbm` and `Benchmark.ips`.
|
54
60
|
|
55
|
-
[unreleased]: https://github.com/MatheusRich/benchable/compare/v0.3.
|
61
|
+
[unreleased]: https://github.com/MatheusRich/benchable/compare/v0.3.1...HEAD
|
56
62
|
[0.1.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.1.0
|
57
63
|
[0.2.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.2.0
|
58
|
-
[0.3.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.0
|
64
|
+
[0.3.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.0
|
65
|
+
[0.3.1]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -123,7 +123,7 @@ You can provide benchmark options by passing a hash to the `Benchable.bench` met
|
|
123
123
|
|
124
124
|
#### Options for `Benchmark.bm` and `Benchmark.bmbm`
|
125
125
|
|
126
|
-
|
126
|
+
The only available option is `width` on `bm` and `bmbm` benchmarks, which specifies the leading spaces for labels on each line. The default width is `20`.
|
127
127
|
|
128
128
|
```ruby
|
129
129
|
Benchable.bench(width: 25) do
|
@@ -133,7 +133,7 @@ end
|
|
133
133
|
|
134
134
|
#### Options for `Benchmark::IPS`
|
135
135
|
|
136
|
-
If you're using `::IPS`, you can pass any option accepted by `Benchmark::IPS`' `config` method.
|
136
|
+
If you're using `::IPS`, you can pass any option accepted by `Benchmark::IPS`'s `config` method.
|
137
137
|
|
138
138
|
```ruby
|
139
139
|
Benchable.bench(:ips, time: 5, warmup: 2) do
|
data/lib/benchable/benchmark.rb
CHANGED
@@ -12,7 +12,7 @@ module Benchable
|
|
12
12
|
DEFAULT_WIDTH = 20
|
13
13
|
BENCHMARK_TYPES = %i[bm bmbm ips memory].freeze
|
14
14
|
|
15
|
-
def initialize(benchmark_type, options
|
15
|
+
def initialize(benchmark_type, **options)
|
16
16
|
@benchmark_type = benchmark_type
|
17
17
|
@options = options
|
18
18
|
|
@@ -53,7 +53,7 @@ module Benchable
|
|
53
53
|
|
54
54
|
def run_benchmark
|
55
55
|
benchmark do |b|
|
56
|
-
b.config(
|
56
|
+
b.config(options) if benchmark_type == :ips
|
57
57
|
|
58
58
|
cases.each do |benchmark_case|
|
59
59
|
b.report(name_for(benchmark_case)) do
|
@@ -70,17 +70,19 @@ module Benchable
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def benchmark(&block)
|
73
|
-
|
73
|
+
if benchmark_type == :memory
|
74
|
+
::Benchmark.public_send(benchmark_type, **benchmark_args, &block)
|
75
|
+
else
|
76
|
+
::Benchmark.public_send(benchmark_type, *benchmark_args, &block)
|
77
|
+
end
|
74
78
|
end
|
75
79
|
|
76
80
|
def benchmark_args
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
args
|
81
|
+
if benchmark_type == :memory
|
82
|
+
options.slice(:quiet)
|
83
|
+
else
|
84
|
+
options[:width] || DEFAULT_WIDTH
|
85
|
+
end
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
data/lib/benchable/version.rb
CHANGED