Skip to content

Instantly share code, notes, and snippets.

@hiroara
hiroara / benchmark.rb
Created May 29, 2014 04:09
Rspec Benchmarking script. Put this file under `spec/supports/` and execute `BENCHMARK=1 rake spec`.
RSpec.configure do |config|
next unless ENV['BENCHMARK'] == '1'
benchmarks = []
metadata_keys = %i[ file_path line_number described_class ]
info_keys = %i[ type ] + metadata_keys + %i[ full_description ]
log_file = Rails.root.join('log', 'rspec_benchmark.csv')
config.before(:suite) do
CSV.open(log_file, "wb") do |csv|
csv << info_keys + %i[ utime stime cutime cstime real]
end