Skip to content

Instantly share code, notes, and snippets.

@srt32
Last active August 29, 2015 13:59
Show Gist options
  • Save srt32/10674145 to your computer and use it in GitHub Desktop.
Save srt32/10674145 to your computer and use it in GitHub Desktop.
benchmark_funds.rake_v0
desc 'Benchmark funds_raised methods'
ITERATIONS = 100_000
task benchmark_sql: :environment do
GC.disable
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('sql') do
ITERATIONS.times do
campaign.funds_raised_sql
Campaign.connection.clear_query_cache
end
end
end
GC.enable
end
task benchmark_ruby: :environment do
GC.disable
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('ruby') do
ITERATIONS.times do
campaign.funds_raised_ruby
Campaign.connection.clear_query_cache
end
end
end
GC.enable
end
@srt32
Copy link
Author

srt32 commented Apr 14, 2014

There is an updated gist at https://gist.github.com/srt32/10687302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment