def search_bench(word, text): iterations = Tools.trange(COUNT) print ('Searching for all occurences of %r using ...' % word) t0 = time.time() so = TextTools.TextSearch(word) for i in iterations: l = so.findall(text) t1 = time.time() count = len(l) print (' - mx.TextSearch.TextSearch().findall(): %5.3f ms (%i)' % ((t1 - t0) / COUNT * 1000.0, count)) t0 = time.time() so = re.compile(word) for i in iterations: l = so.findall(text) t1 = time.time() count = len(l) print (' - re.compile().findall(): %5.3f ms (%i)' % ((t1 - t0) / COUNT * 1000.0, count)) t0 = time.time() for i in iterations: count = text.count(word) t1 = time.time() print (' - text.count(): %5.3f ms (%i)' % ((t1 - t0) / COUNT * 1000.0, count))