Sha256: 2aab69c96eed6f98b96e939c6b8c01769c47be86f0232f91cbba87e96e773749
Contents?: true
Size: 1.06 KB
Versions: 18
Compression:
Stored size: 1.06 KB
Contents
reload!; Benchmark.measure { puts "..."; Note.search('rails test method').all; puts "DONE." } reload! site = Site.first note_scope = site.notes; nil note_ids = note_scope.collect_ids; nil puts "Benchmarking #{note_ids.size} notes" batch_size = 1000 amount = batch_size max_amount = note_ids.size while amount < max_amount batch_ids = note_ids[0, amount] batch_scope = note_scope.scoped(:conditions => { :id => batch_ids }) times = [] 25.times do times << (Benchmark.realtime { batch_scope.search('rails test method').count }) end time = times.sum.to_f / times.size puts "#{amount}; #{time}" amount += batch_size end #------------------------------------------ reload! Note.delete_all('site_id <> 1') batch_size = 1000 amount = 20000 while Note.count >= batch_size while Note.count > amount Note.last.destroy end times = [] 25.times do times << (Benchmark.realtime { Note.search('rails test method').count }) end time = times.sum.to_f / times.size puts "#{amount}; #{time}" amount -= batch_size end
Version data entries
18 entries across 18 versions & 1 rubygems