public
Last active

Performance testing in Rspec

  • Download Gist
rspec performance test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.