Skip to content

Commit 6aaa009

Browse files
committed
speed test
1 parent 21c74f5 commit 6aaa009

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pydatastructs/trees/tests/test_binary_trees.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,25 @@ def test_cpp_BST2():
147147
assert b3.lower_bound(-1) == 7
148148
assert b3.lower_bound(20) is None
149149

150-
test_cpp_BST2()
150+
# test_cpp_BST2()
151151

152+
def test_cpp_BST_speed():
153+
BST = BinarySearchTree
154+
import time
155+
b = BST()
156+
t1 = time.time()
157+
for node in range(-1000,1000):
158+
b.insert(node, node)
159+
t2 = time.time()
160+
b2 = BST(backend=Backend.CPP)
161+
t3 = time.time()
162+
for node in range(-1000,1000):
163+
b2.insert(node, node)
164+
t4 = time.time()
165+
print("Time taken by Python backend: ",t2-t1,"s")
166+
print("Time taken by C++ backend: ",t4-t3,"s")
167+
168+
# test_cpp_BST_speed()
152169

153170
################### Python Tests below ###################
154171

0 commit comments

Comments
 (0)