Skip to content

Instantly share code, notes, and snippets.

@danbronsema
Created December 9, 2011 12:06
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save danbronsema/1451289 to your computer and use it in GitHub Desktop.
Save danbronsema/1451289 to your computer and use it in GitHub Desktop.
Performance testing in Rspec
context 'performance' do
before do
require 'benchmark'
@posts = []
@users = []
8.times do |n|
user = Factory.create(:user)
@users << user
aspect = user.aspects.create(:name => 'people')
connect_users(@user, @aspect0, user, aspect)
post = @user.post(:status_message, :message => "hello#{n}", :to => @aspect1.id)
@posts << post
8.times do |n|
user.comment "yo#{post.message}", :on => post
end
end
end
it 'takes time' do
Benchmark.realtime{
get :index
}.should < 1.5
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment