@@ -0,0 +1,2068 @@
+# Simple benchmark script when searching similar strings by using elasticsearch instead of SimString.%0A# Since Elasticsearch uses Apache Lucene, TF/IDF based searching algorithm, the purpose for searching text will be different from this library.%0A%0Afrom elasticsearch import Elasticsearch%0Afrom benchmarker import Benchmarker%0A%0Aes = Elasticsearch('http://localhost:9200/')%0A%0ASEARCH_COUNT_LIMIT = 10**4%0Aindex = 'simstring'%0Atype = 'sample'%0Apath = './dev/data/company_names.txt'%0Anumber_of_lines = len(open(path).readlines())%0A%0Awith Benchmarker(width=20) as bench:%0A    with open(path, 'r') as lines:%0A        for i, line in enumerate(lines):%0A            strings = line.rstrip('%5Cr%5Cn')%0A            res = es.index(index=index, doc_type=type, id=i, body=%7B'strings': line%7D)%0A%0A    @bench(%22search text(%7B0%7D times)%22.format(min(number_of_lines, SEARCH_COUNT_LIMIT)))%0A    def _(bm):%0A        with open(path, 'r') as lines:%0A            for i, line in enumerate(lines):%0A                strings = line.rstrip('%5Cr%5Cn')%0A                res = es.search(index=index, body=%7B%22query%22: %7B%22match%22: %7B'strings': strings%7D%7D, %22min_score%22: 20%7D)%0A%0A                # print(strings)%0A                # print(%22Got %25d Hits:%22 %25 res%5B'hits'%5D%5B'total'%5D)%0A                # for hit in res%5B'hits'%5D%5B'hits'%5D:%0A                #     print(hit)%0A%0A%0A# $ python dev/benchmark_for_elasticsearch.py%0A# ## benchmarker:         release 4.0.1 (for python)%0A# ## python version:      3.5.5%0A# ## python compiler:     GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)%0A# ## python platform:     Darwin-17.6.0-x86_64-i386-64bit%0A# ## python executable:   /usr/local/miniconda3/envs/myenv/bin/python%0A# ## cpu model:           Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz%0A# ## parameters:          loop=1, cycle=1, extra=0%0A#%0A# ##                        real    (total    = user    + sys)%0A# search text(5797 times)   18.0541    4.9900    4.6500    0.3400%0A#%0A# ## Ranking                real%0A# search text(5797 times)   18.0541  (100.0) ********************%0A#%0A# ## Matrix                 real    %5B01%5D%0A# %5B01%5D search text(5797 times)   18.0541   100.0%0A

Add benchmark script for elasticsearch