Skip to content

Instantly share code, notes, and snippets.

@acook
Forked from gabetax/benchmark.rb
Last active August 29, 2015 13:56
Show Gist options
  • Save acook/9058072 to your computer and use it in GitHub Desktop.
Save acook/9058072 to your computer and use it in GitHub Desktop.
factorygirl*
new*
Gemfile.lock
factory_girl_benchmarks
ruby-2.0.0-p353@rubytesting
#!/usr/bin/ruby
require 'factory_girl'
require 'perftools'
require 'benchmark'
class SomeObject; end
FactoryGirl.define do
factory :some_object do
end
end
TIMES = 100_000
Benchmark.bm do |bm|
bm.report 'FactoryGirl.build' do
PerfTools::CpuProfiler.start("factorygirl") do
TIMES.times { FactoryGirl.build :some_object }
end
end
bm.report 'new' do
PerfTools::CpuProfiler.start("new") do
TIMES.times { SomeObject.new }
end
end
end
source 'https://rubygems.org'
gem 'perftools.rb'
gem 'factory_girl'
user system total real
FactoryGirl.buildPROFILE: interrupts/evictions/bytes = 633/0/32944
6.850000 0.010000 6.860000 ( 6.865386)
newPROFILE: interrupts/evictions/bytes = 2/0/168
0.030000 0.010000 0.040000 ( 0.029475)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment