root/trunk/benchmark_search.rb

Revision 2, 0.6 kB (checked in by astro, 4 years ago)

Initial import

Line 
1 require 'rubygems'
2 $:.unshift('lib')
3 require 'blog'
4
5
6
7 blog = Blog.new('config.yaml')
8
9 WORDS = %w(wapJAB a e n astro blog sch)
10 N = 50
11 time_ruby = 0
12 time_pgsql = 0
13
14 WORDS.each do |word|
15   N.times do
16     s1 = Time.now
17     r_ruby = Entry.search_ruby(word)
18     s2 = Time.now
19     time_ruby += s2 - s1
20
21     s1 = Time.now
22     r_pgsql = Entry.search_pgsql(word)
23     s2 = Time.now
24     time_pgsql += s2 - s1
25
26     if r_ruby.size != r_pgsql.size
27       puts "Result size differs!"
28       exit!
29     end
30   end
31
32   puts "#{N} Ruby  queries for #{word.inspect}: #{time_ruby} sec"
33   puts "#{N} PgSQL queries for #{word.inspect}: #{time_pgsql} sec"
34 end
Note: See TracBrowser for help on using the browser.