def test_multi_test(): t = Tree() t.multi_add(["Hello", "World"]) assert t.multi_is_in(["Hello", "World"]) == [True, True] answer, head, evidence = t.multi_is_in(["Hello", "World"], True) assert answer == [True, True] e = dict((k.identity(), k) for k in evidence) t2 = Tree(e, head) assert t2.multi_is_in(["Hello", "World"]) == [True, True]
def test_multi_test(): t = Tree() t.multi_add([b"Hello", b"World"]) assert t.multi_is_in([b"Hello", b"World"]) == [True, True] answer, head, evidence = t.multi_is_in([b"Hello", b"World"], evidence=True) assert answer == [True, True] e = dict((k.identity(), k) for k in evidence) t2 = Tree(e, head) assert t2.multi_is_in([b"Hello", b"World"]) == [True, True]
def main(): t = Tree() from os import urandom rep = 100000 print("For %s repetitions:" % rep) X = [str(x) for x in xrange(rep)] bulk = ["x" + str(x) for x in xrange(rep)] t.multi_add(bulk) with Timer() as tim: t.multi_add(X) print "Time per add: %.4f ms (total: %.2f sec)" % ( tim.interval * 1000 / float(rep), tim.interval) with Timer() as tim: t.multi_is_in(X) print "Time per check: %.4f ms (total: %.2f sec)" % ( tim.interval * 1000 / float(rep), tim.interval)