Sha256: 979ad09884f3f8d7218d87f26b262c5ca13330bf5f7e5d052b1eb9fdfffb2fc5
Contents?: true
Size: 1.29 KB
Versions: 14
Compression:
Stored size: 1.29 KB
Contents
require 'spec_helper' class UserBenchmarkSpec < MiniTest::Unit::TestCase def test_update_recommendations if ENV["BENCH"] then Recommendable.redis.flushdb @actions = [:like, :dislike] puts "\n" assert_performance_exponential do |n| @user = Factory(:user) @users = [] @movies = [] # Make n users, 5n movies n.times do @users << Factory(:user) @movies << Factory(:movie) @movies << Factory(:movie) @movies << Factory(:movie) @movies << Factory(:movie) @movies << Factory(:movie) end # Main user randomly likes/dislikes 1/4 of the movies @movies.sample(n/4).each do |m| @user.send(@actions.sample, m) end # Other users randomly like/dislike some movies @movies.sample(n/2).each do |m| @users.sample.send(@actions.sample, m) @users.sample.send(@actions.sample, m) @users.sample.send(@actions.sample, m) end @user.send :update_similarities @user.send :update_recommendations Recommendable.redis.flushdb User.delete_all Movie.delete_all Recommendable::Like.delete_all Recommendable::Dislike.delete_all end end end end
Version data entries
14 entries across 14 versions & 1 rubygems