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

Version Path
dusen-0.6.1 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.6.0 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.5.3 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.5.2 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.5.1 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.5 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.11 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.10 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.9 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.8 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.6 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.5 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.4 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.3 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.2 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.1 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.4.0 documents/fulltext_vs_like_benchmark/benchmark.rb
dusen-0.3.0 documents/fulltext_vs_like_benchmark/benchmark.rb