summaryrefslogtreecommitdiffstats
path: root/lib/kross/test/testperformance.py
blob: a76453ed8531bbf16971b063cef81ce2c30b2f7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python

"""
  This Python script is used as performance-tester and profiler
  for the Kross scripting framework.
"""

def runner():
	import krosstestpluginmodule
	testobject1 = krosstestpluginmodule.testpluginobject1()

	def testKexiDB(kexidbfile,drivername,sqlstring):
		print "test kexidb"
		import krosskexidb
		drivermanager = krosskexidb.DriverManager()
		connectiondata = drivermanager.createConnectionData()
		connectiondata.setFileName(kexidbfile)
		driver = drivermanager.driver(drivername)
		connection = driver.createConnection(connectiondata)
		if not connection.connect(): raise "Connect failed"
		if not connection.useDatabase(kexidbfile): raise "Use database failed"
		for i in range(20000):
			cursor = connection.executeQueryString(sqlstring)
			if not cursor: raise "Failed to create cursor"
			cursor.moveFirst()
			while(not cursor.eof()):
				for i in range( cursor.fieldCount() ):
					(item,field,value) = (cursor.at(), i, cursor.value(i))
					cursor.moveNext()

	def test1():
		print "test1"
		for i in range(100000):
			testobject1.func1()
			testobject1.func1()
			testobject1.func1()
			
			testobject1.func2("f2s1","f2s2")
			testobject1.func2("f2s3","f2s4")
			testobject1.func2("f2s5","f2s6")
			
			testobject1.func3("f3s1","f3s2")
			testobject1.func3("f3s3","f3s4")
			testobject1.func3("f3s5","f3s6")

			testobject1.func4("f4s1","f4s2")
			testobject1.func4("f4s3","f4s4")
			testobject1.func4("f4s5","f4s6")

			testobject1.func5("f5s1","f5s2")
			testobject1.func5("f5s3","f5s4")
			testobject1.func5("f5s5","f5s6")

			testobject1.func6( ("One1","Two2"), "haha" )
			testobject1.func6( ("One3","Two4"), 123456789 )
			testobject1.func6( ("One5","Two6"), 12345.67890 )

			testobject1.func7("f5s1",123)
			testobject1.func7("f5s3",456)
			testobject1.func7("f5s5",789)

			testobject1.func8(123,456)
			testobject1.func8(12,34)
			testobject1.func8(1,2)
			
			testobject1.func9(2.0,1.0)
			testobject1.func9(4.0,3.0)
			testobject1.func9(6.0,5.0)

	#test1()
	testKexiDB("/home/snoopy/test.kexi", "SQLite3", "SELECT * FROM dept")

import profile
__main__.runner=runner
profile.run("runner()")