diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-02-03 19:38:50 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-02-03 19:38:50 +0100 |
commit | a6bc5bf8d7d003b6cf4e623485b330e1e2830703 (patch) | |
tree | 0495b71bcb0ec6e9b72dfa954d11c7ed857aee7a /runbenchmark.py | |
parent | Removed import of 'conf' module. (diff) | |
download | newspipe-a6bc5bf8d7d003b6cf4e623485b330e1e2830703.tar.gz newspipe-a6bc5bf8d7d003b6cf4e623485b330e1e2830703.tar.bz2 newspipe-a6bc5bf8d7d003b6cf4e623485b330e1e2830703.zip |
Added naive benchmarks for Whoosh and ElasticSearch.
Diffstat (limited to 'runbenchmark.py')
-rw-r--r-- | runbenchmark.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/runbenchmark.py b/runbenchmark.py new file mode 100644 index 00000000..8241e52b --- /dev/null +++ b/runbenchmark.py @@ -0,0 +1,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
\ No newline at end of file |