From 09f24ee4254ac2c984e7589d6e9d6156cb6e802e Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Tue, 29 Jul 2025 20:47:50 -0500 Subject: [PATCH 1/4] Only test the three latest Rubies Ruby 3.0 and 3.1 are in security maintenance phase and 2.x are all end-of-life. There's not much point continuing to test against them. This ensures we're testing against only relevant versions of Ruby. --- .github/workflows/ci.yaml | 15 ++++----------- README.md | 6 +----- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49a3d5e..4353ae8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.4' - uses: actions/cache@v2 with: @@ -44,13 +44,9 @@ jobs: fail-fast: false matrix: ruby: - - '2.5' - - '2.6' - - '2.7' - - '3.0' - - '3.1' - '3.2' - '3.3' + - '3.4' steps: - uses: actions/checkout@v2 @@ -66,9 +62,6 @@ jobs: restore-keys: | ${{ runner.os }}-${{ matrix.ruby }}- - - name: Ensure proper Bundler installed - if: ${{ matrix.ruby == 2.5 || matrix.ruby == 2.6 }} - run: gem install bundler:2.2.28 - name: Bundle install run: | @@ -79,7 +72,7 @@ jobs: - name: Test without reporting coverage run: bundle exec rspec - if: ${{ matrix.ruby != '2.7' }} + if: ${{ matrix.ruby != '3.4' }} - name: Test and report coverage run: | @@ -88,6 +81,6 @@ jobs: ./cc-test-reporter before-build bundle exec rspec ./cc-test-reporter after-build -t simplecov --exit-code $? - if: ${{ matrix.ruby == '2.7' }} + if: ${{ matrix.ruby == '3.4' }} env: CC_TEST_REPORTER_ID: 36f3969bdc1e5e821f38411648b9ba4217fa4518c9f58c30f0e9b0d1639b4f19 diff --git a/README.md b/README.md index f62edc8..9472080 100644 --- a/README.md +++ b/README.md @@ -171,13 +171,9 @@ When enabling holding, the benchmark writes to the file passed into the `#hold!` This library aims to support and is [tested against][ci] the following Ruby versions: -* Ruby 2.5 -* Ruby 2.6 -* Ruby 2.7 -* Ruby 3.0 -* Ruby 3.1 * Ruby 3.2 * Ruby 3.3 +* Ruby 3.4 If something doesn't work on one of these versions, it's a bug. From 075d19f9990cf0031923c36c96fc42ff8926b0c8 Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Tue, 29 Jul 2025 20:55:44 -0500 Subject: [PATCH 2/4] Update CI to recent versions of actions This change modernizes the CI suite to current standards and action versions so that it is able to run. --- .github/workflows/ci.yaml | 45 ++++++--------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4353ae8..c2621ec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,29 +6,14 @@ on: jobs: lint: name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - uses: ruby/setup-ruby@v1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: ruby/setup-ruby@bb6434c747fa7022e12fa1cae2a0951fcffcff26 # v1.253.0 with: + bundler-cache: true ruby-version: '3.4' - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.ruby }}- - - - run: | - bundle config --local path vendor/bundle - bundle config --local with ci - bundle config --local without "development test" - bundle check || bundle install --jobs 4 --retry 3 - - name: Lint code style run: bundle exec rubocop @@ -37,9 +22,7 @@ jobs: test: name: Test on ${{ matrix.ruby }} - runs-on: ubuntu-latest - strategy: fail-fast: false matrix: @@ -47,29 +30,13 @@ jobs: - '3.2' - '3.3' - '3.4' - steps: - - uses: actions/checkout@v2 - - - uses: ruby/setup-ruby@v1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: ruby/setup-ruby@bb6434c747fa7022e12fa1cae2a0951fcffcff26 # v1.253.0 with: + bundler-cache: true ruby-version: ${{ matrix.ruby }} - - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('benchmark-memory.gemspec', 'Gemfile') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.ruby }}- - - - - name: Bundle install - run: | - bundle config --local path vendor/bundle - bundle config --local with "test" - bundle config --local without "development ci" - bundle check || bundle install --jobs 4 --retry 3 - - name: Test without reporting coverage run: bundle exec rspec if: ${{ matrix.ruby != '3.4' }} From fd957b01df5fa8f398df4741625cbbfe94a1bfea Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Tue, 29 Jul 2025 21:04:08 -0500 Subject: [PATCH 3/4] Update all gems to their most recent versions This also switches out Pry in favor of IRB + Debug. --- Gemfile | 13 +-- Gemfile.lock | 151 ++++++++++++++++++++------------ benchmark-memory.gemspec | 2 + lib/benchmark/memory/helpers.rb | 2 +- lib/benchmark/memory/job.rb | 2 + 5 files changed, 105 insertions(+), 65 deletions(-) diff --git a/Gemfile b/Gemfile index e161a7c..328983b 100644 --- a/Gemfile +++ b/Gemfile @@ -5,22 +5,17 @@ source 'https://rubygems.org' gemspec group :development do + gem 'debug' gem 'guard' gem 'guard-bundler' gem 'guard-inch' gem 'guard-rspec', '~> 4.6' gem 'guard-rubocop' + gem 'inch' + gem 'irb' gem 'rake', '>= 12.3.3' + gem 'rubocop', '~> 1' gem 'yard', '~> 0.9.36' - - group :ci do - gem 'inch' - gem 'rubocop', '~> 1' - end - - group :test do - gem 'pry' - end end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index f33d55c..9644df8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,23 +7,33 @@ PATH GEM remote: https://rubygems.org/ specs: - ast (2.4.2) + ast (2.4.3) + bigdecimal (3.2.2) coderay (1.1.3) - diff-lcs (1.4.4) - docile (1.3.5) - ffi (1.13.1) - formatador (0.2.5) - guard (2.16.2) + date (3.4.1) + debug (1.11.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.6.2) + docile (1.4.1) + erb (5.0.2) + ffi (1.17.2) + formatador (1.1.1) + guard (2.19.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) + logger (~> 1.6) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) - pry (>= 0.9.12) + ostruct (~> 0.6) + pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) - guard-bundler (0.1.2) - guard (>= 0.2.2) + guard-bundler (3.0.1) + bundler (>= 2.1, < 3) + guard (~> 2.2) + guard-compat (~> 1.1) guard-compat (1.2.1) guard-inch (0.2.0) guard (~> 2) @@ -32,7 +42,7 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - guard-rubocop (1.4.0) + guard-rubocop (1.5.0) guard (~> 2.0) rubocop (< 2.0) inch (0.8.0) @@ -40,85 +50,116 @@ GEM sparkr (>= 0.2.0) term-ansicolor yard (~> 0.9.12) - listen (3.3.1) + io-console (0.8.1) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - lumberjack (1.2.8) - memory_profiler (1.0.0) - method_source (1.0.0) + logger (1.7.0) + lumberjack (1.3.3) + memory_profiler (1.1.0) + method_source (1.1.0) nenv (0.3.0) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.20.1) - parser (3.0.0.0) + ostruct (0.6.3) + parallel (1.27.0) + parser (3.3.9.0) ast (~> 2.4.1) - pry (0.14.2) + racc + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + prism (1.4.0) + pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - rainbow (3.0.0) - rake (13.0.1) - rb-fsevent (0.10.4) - rb-inotify (0.10.1) + psych (5.2.6) + date + stringio + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.0) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - regexp_parser (2.1.1) - rexml (3.3.6) - strscan - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.0) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.0) + rdoc (6.14.2) + erb + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.2) + io-console (~> 0.5) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.0) - rubocop (1.11.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.4) + rubocop (1.79.0) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.2.0, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - ruby-progressbar (1.11.0) + tsort (>= 0.2.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) shellany (0.0.1) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.2) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) sparkr (0.4.1) - strscan (3.1.0) + stringio (3.1.7) sync (0.5.0) - term-ansicolor (1.7.1) + term-ansicolor (1.11.2) tins (~> 1.0) - thor (1.0.1) - tins (1.26.0) + thor (1.4.0) + tins (1.38.0) + bigdecimal sync - unicode-display_width (2.0.0) - yard (0.9.36) + tsort (0.2.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + yard (0.9.37) PLATFORMS ruby DEPENDENCIES benchmark-memory! + debug guard guard-bundler guard-inch guard-rspec (~> 4.6) guard-rubocop inch - pry + irb rake (>= 12.3.3) rspec (~> 3.4) rubocop (~> 1) @@ -126,4 +167,4 @@ DEPENDENCIES yard (~> 0.9.36) BUNDLED WITH - 2.2.28 + 2.7.1 diff --git a/benchmark-memory.gemspec b/benchmark-memory.gemspec index 4792c58..de429d0 100644 --- a/benchmark-memory.gemspec +++ b/benchmark-memory.gemspec @@ -18,6 +18,8 @@ Gem::Specification.new do |spec| spec.files += Dir['lib/**/*.rb'] spec.require_paths = ['lib'] + spec.metadata['rubygems_mfa_required'] = 'true' + spec.required_ruby_version = '>= 2.5.0' spec.add_dependency 'memory_profiler', '~> 1' diff --git a/lib/benchmark/memory/helpers.rb b/lib/benchmark/memory/helpers.rb index c2c3b29..6fa5197 100644 --- a/lib/benchmark/memory/helpers.rb +++ b/lib/benchmark/memory/helpers.rb @@ -31,7 +31,7 @@ def scale(value) format("%10.3f#{value.unit}", value.to_f / (1000**value.scale)) end - module_function :scale # rubocop:disable Style/AccessModifierDeclarations + module_function :scale end end end diff --git a/lib/benchmark/memory/job.rb b/lib/benchmark/memory/job.rb index aedd8e1..7de574c 100644 --- a/lib/benchmark/memory/job.rb +++ b/lib/benchmark/memory/job.rb @@ -121,6 +121,7 @@ def quiet? private + # rubocop:disable Naming/PredicateMethod def run_with_held_results(task) measurement = @held_results[task.label] full_report.add_entry(task, measurement) @@ -140,6 +141,7 @@ def run_without_held_results(task) @held_results.holding? end end + # rubocop:enable Naming/PredicateMethod end end end From 9fd3501b4f17d2600eef369271b68d59c76ac28d Mon Sep 17 00:00:00 2001 From: Michael Herold Date: Tue, 29 Jul 2025 21:09:33 -0500 Subject: [PATCH 4/4] Drop Code Climate and Inch CI I don't care to use Code Climate anymore and Inch CI is down currently so there's no reason to link to it. --- .github/workflows/ci.yaml | 14 +------------- README.md | 8 -------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c2621ec..b6a2a8a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,17 +37,5 @@ jobs: bundler-cache: true ruby-version: ${{ matrix.ruby }} - - name: Test without reporting coverage + - name: Run test suite run: bundle exec rspec - if: ${{ matrix.ruby != '3.4' }} - - - name: Test and report coverage - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build - bundle exec rspec - ./cc-test-reporter after-build -t simplecov --exit-code $? - if: ${{ matrix.ruby == '3.4' }} - env: - CC_TEST_REPORTER_ID: 36f3969bdc1e5e821f38411648b9ba4217fa4518c9f58c30f0e9b0d1639b4f19 diff --git a/README.md b/README.md index 9472080..536b926 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,5 @@ # benchmark-memory -[![CI](https://github.com/michaelherold/benchmark-memory/workflows/CI/badge.svg)][ci] -[![Code Climate](https://codeclimate.com/github/michaelherold/benchmark-memory/badges/gpa.svg)][codeclimate] -[![Inline docs](http://inch-ci.org/github/michaelherold/benchmark-memory.svg?branch=main)][inch] - -[ci]: https://github.com/michaelherold/benchmark-memory/actions -[codeclimate]: https://codeclimate.com/github/michaelherold/benchmark-memory -[inch]: http://inch-ci.org/github/michaelherold/benchmark-memory - benchmark-memory is a tool that helps you to benchmark the memory usage of different pieces of code. It leverages the power of [memory_profiler] to give you a metric of the total amount of memory allocated and retained by a block, as well as the number of objects and strings allocated and retained. [memory_profiler]: https://github.com/SamSaffron/memory_profiler