Skip to content

Instantly share code, notes, and snippets.

@gabetax
Created March 9, 2013 02:50
Show Gist options
  • Save gabetax/5122270 to your computer and use it in GitHub Desktop.
Save gabetax/5122270 to your computer and use it in GitHub Desktop.
FactoryGirl.build on a PORO with no defined attributes vs #new
require 'perftools'
TIMES = 100_000
Benchmark.bm do |bm|
bm.report 'FactoryGirl.build' do
PerfTools::CpuProfiler.start("factorygirl") do
TIMES.times { FactoryGirl.build :loans_search_form }
end
end
bm.report 'new' do
PerfTools::CpuProfiler.start("new") do
TIMES.times { LoansSearchForm.new }
end
end
end
FactoryGirl.define do
factory :loans_search_form do
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment