A lightweight gem for benchmarking garbage collect stats relevant to memory optimization.
Add this line to your application's Gemfile:
gem 'benchmark_g_c'And then execute:
$ bundle
Or install it yourself as:
$ gem install benchmark_g_c
class Thing
include BenchmarkGC
# A method you want to benchmark
def method_name
do_some_stuff
end
# Add this method in order to benchmark (name doesn't matter)
def check
bcheck { method_name }
end
endIn a console:
Thing.new.check- name: (string) Print the name of the benchmarked code
- times: (integer) Number of times to run the benchmarked code in succession
- logger: (boolean)
ActiveRecord::Base.loggershould log
class Thing
...
def method_name
bcheck { do_some_stuff }
end
endNow you can run any code that uses method_name, and method_name will get benchmarked each time it is run.
The gem is available as open source under the terms of the MIT License.