Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Created May 19, 2012 01:49
Show Gist options
  • Save dmitryrck/2728554 to your computer and use it in GitHub Desktop.
Save dmitryrck/2728554 to your computer and use it in GitHub Desktop.
require 'benchmark'
require File.dirname(__FILE__)+"/config/environment"
DEFAULT = 10_000
Benchmark.bm do |x|
x.report do
DEFAULT.times do |num|
Page.create :title => num, :content => num, :slug => num, :slug => num
end
end
x.report('TITLE1') do
DEFAULT.times do |num|
Page.where(:title => num).first
end
end
x.report('TITLE3') do
DEFAULT.times do |num|
page = Page.where(:title => num).first
page.title = "#{num}title"
page.content = "#{num}content"
page.save
end
end
x.report('b4') do
DEFAULT.times do |num|
Page.where(:slug => num).first.delete
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment