Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 9 additions & 61 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,13 @@ on:
jobs:
lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'

- uses: actions/cache@v2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ruby/setup-ruby@bb6434c747fa7022e12fa1cae2a0951fcffcff26 # v1.253.0
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
bundler-cache: true
ruby-version: '3.4'

- name: Lint code style
run: bundle exec rubocop
Expand All @@ -37,57 +22,20 @@ jobs:

test:
name: Test on ${{ matrix.ruby }}

runs-on: ubuntu-latest

strategy:
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

- 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: Ensure proper Bundler installed
if: ${{ matrix.ruby == 2.5 || matrix.ruby == 2.6 }}
run: gem install bundler:2.2.28

- 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
- name: Run test suite
run: bundle exec rspec
if: ${{ matrix.ruby != '2.7' }}

- 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 == '2.7' }}
env:
CC_TEST_REPORTER_ID: 36f3969bdc1e5e821f38411648b9ba4217fa4518c9f58c30f0e9b0d1639b4f19
13 changes: 4 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
151 changes: 96 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,98 +42,129 @@ 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)
pry
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)
simplecov (> 0.20)
yard (~> 0.9.36)

BUNDLED WITH
2.2.28
2.7.1
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -171,13 +163,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.

Expand Down
2 changes: 2 additions & 0 deletions benchmark-memory.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/benchmark/memory/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading