Skip to content

Commit cfd59d3

Browse files
committed
Added tier 1 performance test
1 parent ea11522 commit cfd59d3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test-performance/timesInsert.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import time
2+
import pynuodb
3+
4+
smallIterations = 100
5+
largeIterations = smallIterations * 1000
6+
7+
dropTable = "drop table perf_test cascade if exists"
8+
createTable = "create table perf_test (a int,b char)"
9+
#A database named test with user dba and password dba must be created before running
10+
connection = pynuodb.connect("dba", "localhost", "dba", "dba")
11+
cursor = connection.cursor()
12+
13+
cursor.execute("use test")
14+
cursor.execute(dropTable)
15+
cursor.execute(createTable)
16+
17+
""" Begin SMALL_INSERT_ITERATIONS test"""
18+
19+
smallIterationsInsertTime = time.clock()
20+
for i in range(smallIterations):
21+
cursor.execute("INSERT INTO perf_test (a,b ) VALUES (%s,'A')" % i)
22+
connection.commit()
23+
smallIterationsInsertTime = time.clock() - smallIterationsInsertTime
24+
25+
print("\n Elapse time of SMALL_INSERT_ITERATIONS = " + str(smallIterationsInsertTime))
26+
27+
""" Begin SMALL_SELECT_ITERATIONS test"""
28+
29+
smallIterationsSelectTime = time.clock()
30+
cursor.execute("select * from perf_test")
31+
cursor.fetchall()
32+
smallIterationsSelectTime = time.clock() - smallIterationsSelectTime
33+
print("\n Elapse time of SMALL_SELECT_ITERATIONS = " + str(smallIterationsSelectTime))
34+
35+
""" Begin LARGE_INSERT_ITERATIONS test"""
36+
cursor.execute(dropTable)
37+
cursor.execute(createTable)
38+
39+
largeIterationsInsertTime = time.clock()
40+
for i in range(largeIterations):
41+
cursor.execute("INSERT INTO perf_test (a,b ) VALUES (%s,'A')" % i)
42+
connection.commit()
43+
largeIterationsInsertTime = time.clock() - largeIterationsInsertTime
44+
45+
print("\n Elapse time of LARGE_INSERT_ITERATIONS = " + str(largeIterationsInsertTime))
46+
47+
""" Begin LARGE_SELECT_ITERATIONS test"""
48+
49+
largeIterationsSelectTime = time.clock()
50+
cursor.execute("select * from perf_test")
51+
cursor.fetchall()
52+
largeIterationsSelectTime = time.clock() - largeIterationsSelectTime
53+
54+
print("\n Elapse time of LARGE_SELECT_ITERATIONS = " + str(largeIterationsSelectTime))
55+
56+
if largeIterationsInsertTime > smallIterationsInsertTime * 1000 :
57+
print("Insert is too slow!")
58+
59+
if largeIterationsSelectTime > smallIterationsSelectTime * 1000 :
60+
print("Select is too slow!")

0 commit comments

Comments
 (0)