blob: 8241e52b2bce0990740789e0c8af3ff0a1592db2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#! /usr/bin/env python
#-*- coding: utf-8 -*-
import time
from benchmark import testelasticsearch
from benchmark import testwhoosh
import conf
from pyaggr3g470r import models
models.connect(conf.DATABASE_NAME)
articles = models.Article.objects()
#
# Index generation
#
print "Indexes generation..."
# Whoosh
print "Whoosh"
begin = time.time()
testwhoosh.create_index(articles)
end = time.time()
print end - begin
print
# ElasticSearch
print "ElasticSearch"
testelasticsearch.delete_index()
begin = time.time()
testelasticsearch.create_index(articles)
end = time.time()
print end - begin
print
print
print
#
# Search
#
print "Search..."
for query in ["Edward Snowden", "Saint-Pierre-et-Miquelon", "micropatronage"]:
print "Query:", query
# Whoosh
print "with Whoosh"
for _ in range(5):
begin = time.time()
testwhoosh.search(query)
end = time.time()
print end - begin
print
# ElasticSearch
print "with ElasticSearch"
for _ in range(5):
begin = time.time()
testelasticsearch.search(query)
end = time.time()
print end - begin
print
print
|