benchable 0.3.0 → 0.3.2

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: f8cc2eab98fd2843682811029e789c3d50f28cef0cab9e607936700579e65cf6
4
- data.tar.gz: 38f5b868dece18aaf0567603346ff9677b998486c12236a6915cfbedac0ead13
3
+ metadata.gz: 87cc0bd81e3bc20d1cff1143def72c70684a065f40b0077d709624a0303a1dd3
4
+ data.tar.gz: d8346382a1e72d1c39dc36ebf55089a0f85816445ce35f80c53f68e059d50266
5
5
  SHA512:
6
- metadata.gz: 555bcfbff720e4f8044504d7055da3b265f3adf0ad73ba8039dd6f3cc31de82cce6932ce100934ddc72356c2e59021334fa9f83eab31f3e9d090f5d9d88d7aed
7
- data.tar.gz: dbc3b735b5400fa4cd948bc4535cb2a5d2998463b8411b72cd569171dff21058bd89bb6d9c73a2f58d5cd3fdfe4470fbc1d636832c3fa5bbf00b45075afefbb1
6
+ metadata.gz: efae28a9f656b930e64ed9b443a9b75d50199de020c8a18e15b6e2fd648beae2a3bcf9915f31b9bae42988affac526c2908d8237e982b157a7fbc10f0d534f8d
7
+ data.tar.gz: 4f6cdd10159e9251eb7dabae2f16b7fcfb9909d8e252027b2dc12e8b070b1aec0095ea09c1cfbdc69c9d2d3a8384e8ff7bba19ec0b53f6456ea015cb3ceba726
@@ -2,19 +2,19 @@ name: Ruby
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [master]
5
+ branches: [main]
6
6
  pull_request:
7
- branches: [master]
7
+ branches: [main]
8
8
 
9
9
  jobs:
10
10
  build:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby: [2.6, 2.7, '3.0']
14
+ ruby: ['3.1', '3.2', '3.3', '3.4']
15
15
 
16
16
  steps:
17
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v4
18
18
  - name: Set up Ruby ${{ matrix.ruby }}
19
19
  uses: ruby/setup-ruby@v1
20
20
  with:
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.4.4
data/CHANGELOG.md CHANGED
@@ -6,8 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
+
9
10
  ---
10
11
 
12
+ ## [0.3.2] - 2025-05-29
13
+
14
+ ### Changed
15
+
16
+ - Keep benchmark cases titles consistent
17
+
18
+ Before, we would call "capitalize" on the title of the benchmark case, which
19
+ would change the original string the user provided. This fixes it, so the report
20
+ always uses the original title.
21
+
22
+ ## [0.3.1] - 2021-09-10
23
+
24
+ ### Changed
25
+
26
+ - Fix benchmark arguments for Benchmark::Memory.
27
+
11
28
  ## [0.3.0] - 2021-09-09
12
29
 
13
30
  ### Added
@@ -42,6 +59,7 @@ end
42
59
  ## [0.2.0] - 2020-10-23
43
60
 
44
61
  ### Added
62
+
45
63
  - Support for `Benchmark.memory` via [benchmark-memory](https://github.com/michaelherold/benchmark-memory).
46
64
 
47
65
  [unreleased]: https://github.com/MatheusRich/benchable/compare/v0.2.0...HEAD
@@ -50,9 +68,12 @@ end
50
68
  ## [0.1.0] - 2020-08-16
51
69
 
52
70
  ### Added
71
+
53
72
  - Support for `Benchmark.bm`, `Benchmark.bmbm` and `Benchmark.ips`.
54
73
 
55
- [unreleased]: https://github.com/MatheusRich/benchable/compare/v0.3.0...HEAD
56
- [0.1.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.1.0
74
+ [unreleased]: https://github.com/MatheusRich/benchable/compare/v0.3.2...HEAD
75
+ [0.3.2]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.2
76
+ [0.3.1]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.1
77
+ [0.3.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.3.0
57
78
  [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
79
+ [0.1.0]: https://github.com/MatheusRich/benchable/releases/tag/v0.1.0
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ gemspec
8
8
  gem "guard-rspec", require: false
9
9
  gem "rake", "~> 12.0"
10
10
  gem "rspec", "~> 3.0"
11
- gem "standard", "~> 1.3.0"
12
- gem "simplecov", "~> 0.18.5", require: false
13
- gem "solargraph", "~> 0.39"
11
+ gem "standard", "~> 1.30"
12
+ gem "simplecov", "~> 0.22.0", require: false
14
13
  gem "yard", "~> 0.9.25"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- benchable (0.2.0)
4
+ benchable (0.3.2)
5
5
  benchmark-ips (~> 2.8, >= 2.8.2)
6
6
  benchmark-memory (~> 0.1.2)
7
7
 
@@ -9,18 +9,15 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ast (2.4.2)
12
- backport (1.2.0)
13
- benchmark (0.1.1)
14
- benchmark-ips (2.9.1)
12
+ benchmark-ips (2.14.0)
15
13
  benchmark-memory (0.1.2)
16
14
  memory_profiler (~> 0.9)
17
15
  coderay (1.1.3)
18
- diff-lcs (1.4.4)
19
- docile (1.4.0)
20
- e2mmap (0.1.0)
21
- ffi (1.15.4)
22
- formatador (0.3.0)
23
- guard (2.18.0)
16
+ diff-lcs (1.5.1)
17
+ docile (1.4.1)
18
+ ffi (1.17.0)
19
+ formatador (1.1.0)
20
+ guard (2.19.0)
24
21
  formatador (>= 0.2.4)
25
22
  listen (>= 2.7, < 4.0)
26
23
  lumberjack (>= 1.0.12, < 2.0)
@@ -34,96 +31,86 @@ GEM
34
31
  guard (~> 2.1)
35
32
  guard-compat (~> 1.1)
36
33
  rspec (>= 2.99.0, < 4.0)
37
- jaro_winkler (1.5.4)
38
- kramdown (2.3.1)
39
- rexml
40
- kramdown-parser-gfm (1.1.0)
41
- kramdown (~> 2.0)
42
- listen (3.7.0)
34
+ json (2.9.1)
35
+ language_server-protocol (3.17.0.3)
36
+ lint_roller (1.1.0)
37
+ listen (3.9.0)
43
38
  rb-fsevent (~> 0.10, >= 0.10.3)
44
39
  rb-inotify (~> 0.9, >= 0.9.10)
45
- lumberjack (1.2.8)
40
+ lumberjack (1.2.10)
46
41
  memory_profiler (0.9.14)
47
- method_source (1.0.0)
48
- mini_portile2 (2.6.1)
42
+ method_source (1.1.0)
49
43
  nenv (0.3.0)
50
- nokogiri (1.12.4)
51
- mini_portile2 (~> 2.6.1)
52
- racc (~> 1.4)
53
44
  notiffany (0.1.3)
54
45
  nenv (~> 0.1)
55
46
  shellany (~> 0.0)
56
- parallel (1.20.1)
57
- parser (3.0.2.0)
47
+ parallel (1.26.3)
48
+ parser (3.3.6.0)
58
49
  ast (~> 2.4.1)
59
- pry (0.14.1)
50
+ racc
51
+ pry (0.15.2)
60
52
  coderay (~> 1.1)
61
53
  method_source (~> 1.0)
62
- racc (1.5.2)
63
- rainbow (3.0.0)
54
+ racc (1.8.1)
55
+ rainbow (3.1.1)
64
56
  rake (12.3.3)
65
- rb-fsevent (0.11.0)
66
- rb-inotify (0.10.1)
57
+ rb-fsevent (0.11.2)
58
+ rb-inotify (0.11.1)
67
59
  ffi (~> 1.0)
68
- regexp_parser (2.1.1)
69
- reverse_markdown (2.0.0)
70
- nokogiri
71
- rexml (3.2.5)
72
- rspec (3.10.0)
73
- rspec-core (~> 3.10.0)
74
- rspec-expectations (~> 3.10.0)
75
- rspec-mocks (~> 3.10.0)
76
- rspec-core (3.10.1)
77
- rspec-support (~> 3.10.0)
78
- rspec-expectations (3.10.1)
60
+ regexp_parser (2.10.0)
61
+ rspec (3.13.0)
62
+ rspec-core (~> 3.13.0)
63
+ rspec-expectations (~> 3.13.0)
64
+ rspec-mocks (~> 3.13.0)
65
+ rspec-core (3.13.2)
66
+ rspec-support (~> 3.13.0)
67
+ rspec-expectations (3.13.3)
79
68
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.10.0)
81
- rspec-mocks (3.10.2)
69
+ rspec-support (~> 3.13.0)
70
+ rspec-mocks (3.13.2)
82
71
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.10.0)
84
- rspec-support (3.10.2)
85
- rubocop (1.20.0)
72
+ rspec-support (~> 3.13.0)
73
+ rspec-support (3.13.2)
74
+ rubocop (1.69.2)
75
+ json (~> 2.3)
76
+ language_server-protocol (>= 3.17.0)
86
77
  parallel (~> 1.10)
87
- parser (>= 3.0.0.0)
78
+ parser (>= 3.3.0.2)
88
79
  rainbow (>= 2.2.2, < 4.0)
89
- regexp_parser (>= 1.8, < 3.0)
90
- rexml
91
- rubocop-ast (>= 1.9.1, < 2.0)
80
+ regexp_parser (>= 2.9.3, < 3.0)
81
+ rubocop-ast (>= 1.36.2, < 2.0)
92
82
  ruby-progressbar (~> 1.7)
93
- unicode-display_width (>= 1.4.0, < 3.0)
94
- rubocop-ast (1.11.0)
95
- parser (>= 3.0.1.1)
96
- rubocop-performance (1.11.5)
97
- rubocop (>= 1.7.0, < 2.0)
98
- rubocop-ast (>= 0.4.0)
99
- ruby-progressbar (1.11.0)
83
+ unicode-display_width (>= 2.4.0, < 4.0)
84
+ rubocop-ast (1.37.0)
85
+ parser (>= 3.3.1.0)
86
+ rubocop-performance (1.23.0)
87
+ rubocop (>= 1.48.1, < 2.0)
88
+ rubocop-ast (>= 1.31.1, < 2.0)
89
+ ruby-progressbar (1.13.0)
100
90
  shellany (0.0.1)
101
- simplecov (0.18.5)
91
+ simplecov (0.22.0)
102
92
  docile (~> 1.1)
103
93
  simplecov-html (~> 0.11)
104
- simplecov-html (0.12.3)
105
- solargraph (0.43.0)
106
- backport (~> 1.2)
107
- benchmark
108
- bundler (>= 1.17.2)
109
- diff-lcs (~> 1.4)
110
- e2mmap
111
- jaro_winkler (~> 1.5)
112
- kramdown (~> 2.3)
113
- kramdown-parser-gfm (~> 1.1)
114
- parser (~> 3.0)
115
- reverse_markdown (>= 1.0.5, < 3)
116
- rubocop (>= 0.52)
117
- thor (~> 1.0)
118
- tilt (~> 2.0)
119
- yard (~> 0.9, >= 0.9.24)
120
- standard (1.3.0)
121
- rubocop (= 1.20.0)
122
- rubocop-performance (= 1.11.5)
123
- thor (1.1.0)
124
- tilt (2.0.10)
125
- unicode-display_width (2.0.0)
126
- yard (0.9.26)
94
+ simplecov_json_formatter (~> 0.1)
95
+ simplecov-html (0.13.1)
96
+ simplecov_json_formatter (0.1.4)
97
+ standard (1.43.0)
98
+ language_server-protocol (~> 3.17.0.2)
99
+ lint_roller (~> 1.0)
100
+ rubocop (~> 1.69.1)
101
+ standard-custom (~> 1.0.0)
102
+ standard-performance (~> 1.6)
103
+ standard-custom (1.0.2)
104
+ lint_roller (~> 1.0)
105
+ rubocop (~> 1.50)
106
+ standard-performance (1.6.0)
107
+ lint_roller (~> 1.1)
108
+ rubocop-performance (~> 1.23.0)
109
+ thor (1.3.2)
110
+ unicode-display_width (3.1.3)
111
+ unicode-emoji (~> 4.0, >= 4.0.4)
112
+ unicode-emoji (4.0.4)
113
+ yard (0.9.37)
127
114
 
128
115
  PLATFORMS
129
116
  ruby
@@ -133,10 +120,9 @@ DEPENDENCIES
133
120
  guard-rspec
134
121
  rake (~> 12.0)
135
122
  rspec (~> 3.0)
136
- simplecov (~> 0.18.5)
137
- solargraph (~> 0.39)
138
- standard (~> 1.3.0)
123
+ simplecov (~> 0.22.0)
124
+ standard (~> 1.30)
139
125
  yard (~> 0.9.25)
140
126
 
141
127
  BUNDLED WITH
142
- 2.1.4
128
+ 2.6.2
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
- On `bm` and `bmbm` benchmarks the only available option is `width`, which specifies the leading spaces for labels on each line. The default width is `20`.
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/benchable.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  # spec.description = %q{TODO: Write a longer description or delete this line.}
13
13
  spec.homepage = "https://github.com/MatheusRich/benchable"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/MatheusRich/benchable"
@@ -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
 
@@ -24,7 +24,7 @@ module Benchable
24
24
  end
25
25
 
26
26
  def self.bench(name, &block)
27
- define_method(method_name_for(name), &block)
27
+ define_method(:"bench_#{name}", &block)
28
28
  end
29
29
 
30
30
  def setup
@@ -39,10 +39,6 @@ module Benchable
39
39
  public_methods.grep(/\Abench_/)
40
40
  end
41
41
 
42
- private_class_method def self.method_name_for(name)
43
- "bench_#{name.to_s.tr(" ", "_").downcase}"
44
- end
45
-
46
42
  private
47
43
 
48
44
  attr_reader :benchmark_type, :options
@@ -53,10 +49,10 @@ module Benchable
53
49
 
54
50
  def run_benchmark
55
51
  benchmark do |b|
56
- b.config(**options) if benchmark_type == :ips
52
+ b.config(options) if benchmark_type == :ips
57
53
 
58
54
  cases.each do |benchmark_case|
59
- b.report(name_for(benchmark_case)) do
55
+ b.report(title_for(benchmark_case)) do
60
56
  method(benchmark_case).call
61
57
  end
62
58
  end
@@ -65,22 +61,24 @@ module Benchable
65
61
  end
66
62
  end
67
63
 
68
- def name_for(benchmark_case)
69
- benchmark_case.to_s.gsub("bench_", "").tr("_", " ").capitalize
64
+ def title_for(benchmark_case)
65
+ benchmark_case.to_s.delete_prefix("bench_")
70
66
  end
71
67
 
72
68
  def benchmark(&block)
73
- ::Benchmark.public_send(*benchmark_args, &block)
69
+ if benchmark_type == :memory
70
+ ::Benchmark.public_send(benchmark_type, **benchmark_args, &block)
71
+ else
72
+ ::Benchmark.public_send(benchmark_type, *benchmark_args, &block)
73
+ end
74
74
  end
75
75
 
76
76
  def benchmark_args
77
- width = options[:width] || DEFAULT_WIDTH
78
-
79
- args = [benchmark_type]
80
- args << width unless benchmark_type == :memory
81
- args << options if benchmark_type == :memory
82
-
83
- args
77
+ if benchmark_type == :memory
78
+ options.slice(:quiet)
79
+ else
80
+ options[:width] || DEFAULT_WIDTH
81
+ end
84
82
  end
85
83
  end
86
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Benchable
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Richard
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: benchmark-ips
@@ -44,7 +43,6 @@ dependencies:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
45
  version: 0.1.2
47
- description:
48
46
  email:
49
47
  - matheusrichardt@gmail.com
50
48
  executables: []
@@ -54,6 +52,7 @@ files:
54
52
  - ".github/workflows/tests-and-linter.yml"
55
53
  - ".gitignore"
56
54
  - ".rspec"
55
+ - ".tool-versions"
57
56
  - CHANGELOG.md
58
57
  - CODE_OF_CONDUCT.md
59
58
  - Gemfile
@@ -75,7 +74,6 @@ metadata:
75
74
  homepage_uri: https://github.com/MatheusRich/benchable
76
75
  source_code_uri: https://github.com/MatheusRich/benchable
77
76
  changelog_uri: https://github.com/MatheusRich/benchable/blob/master/CHANGELOG.md
78
- post_install_message:
79
77
  rdoc_options: []
80
78
  require_paths:
81
79
  - lib
@@ -83,15 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
81
  requirements:
84
82
  - - ">="
85
83
  - !ruby/object:Gem::Version
86
- version: 2.6.0
84
+ version: 3.0.0
87
85
  required_rubygems_version: !ruby/object:Gem::Requirement
88
86
  requirements:
89
87
  - - ">="
90
88
  - !ruby/object:Gem::Version
91
89
  version: '0'
92
90
  requirements: []
93
- rubygems_version: 3.2.25
94
- signing_key:
91
+ rubygems_version: 3.6.7
95
92
  specification_version: 4
96
93
  summary: Write benchmarks without the hassle
97
94
  test_files: []