changed the benchmark to use different counts of threads
This commit is contained in:
parent
e14c7ee9ac
commit
e2a4d6584b
|
@ -4,6 +4,21 @@ require 'benchmark'
|
|||
require 'virtus'
|
||||
require 'polecat'
|
||||
|
||||
n = 2500
|
||||
|
||||
def run_threads threadcount, count, searcher, query
|
||||
threads = []
|
||||
count = count / threadcount
|
||||
threadcount.times do
|
||||
threads << Thread.new do
|
||||
for i in 1..count do
|
||||
searcher.search query
|
||||
end
|
||||
end
|
||||
end
|
||||
threads.each {|t| t.join }
|
||||
end
|
||||
|
||||
class Document
|
||||
include Virtus
|
||||
|
||||
|
@ -26,10 +41,9 @@ writer.write
|
|||
searcher = Polecat::IndexSearcher.new :reader => writer.create_reader
|
||||
query = Polecat::Query.new.add(Polecat::Term.new(:name, :lt, 25000))
|
||||
|
||||
puts Benchmark.bm { |x|
|
||||
x.report('search') {
|
||||
for i in 1..5000 do
|
||||
searcher.search query
|
||||
end
|
||||
}
|
||||
}
|
||||
Benchmark.bm do |x|
|
||||
x.report('1') { run_threads 1, n, searcher, query.dup }
|
||||
x.report('2') { run_threads 1, n, searcher, query.dup }
|
||||
x.report('4') { run_threads 1, n, searcher, query.dup }
|
||||
x.report('8') { run_threads 1, n, searcher, query.dup }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue