/
TestDB.py
112 lines (104 loc) · 4.31 KB
/
TestDB.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
'''
Performs several tests of the name database
This script tests the DB module and the db-1k.sqlite and db-100k.sqlite names databases.
This is the database that the 'name-dialer' example application is based on.
Part of the AT&T Statistical Dialog Toolkit (ASDT).
Jason D. Williams
jdw@research.att.com
www.research.att.com/people/Williams_Jason_D
'''
# Extend sys.path to include src directory
import os, sys
#sys.path.append(os.path.join(os.path.dirname(__file__),'../../src'))
import logging.config
from DB import InitDB, GetDB, KillDB
from GlobalConfig import InitConfig, GetConfig
DBs = ['LGdb']
def main():
InitConfig()
config = GetConfig()
config.add_section('DB')
logging.config.fileConfig('logging.conf')
for dbStem in DBs:
config.set('DB','dbStem',dbStem)
InitDB()
db = GetDB()
dbFile = db.GetDBFile()
print '*** START : DB = %s ***' % (dbFile)
print 'Records = %d' % (db.rowCount)
tests = [
{
'desc' : 'Get count of all listings with a particular first name',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : 0,
'destination' : 0,
'time' : 0,
},
},
{
'desc' : 'Get count of all listings with a particular first name and last name',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : None,
'destination' : 0,
'time' : 0,
},
},
{
'desc' : 'Get count of all listings with a particular first name, last name, city, and state',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : None,
'destination' : None,
'time' : None,
},
},
{
'desc' : 'Get count of all listings with a particular first name and excluding 50 last names',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : 1,
'destination' : 0,
'time' : 0,
},
},
{
'desc' : 'Get count of all listings with a particular first name and excluding 50 last names, 50 cities, and 40 states',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : 1,
'destination' : 1,
'time' : 1,
},
},
{
'desc' : 'Get count of all listings with a particular first name and excluding 1 last name, 1 city, and 1 state',
'N' : 1,
'spec' : {
'bus' : None,
'origin' : 1,
'destination' : 1,
'time' : 1,
},
},
]
for (i,test) in enumerate(tests):
print '*** TEST %d : DB = %s ***' % (i,dbFile)
print 'Description: %s' % (test['desc'])
print 'Spec: %s' % (test['spec'])
print 'N: %d' % (test['N'])
(avRandTime,avQueryTime,longestQueryTime,avReturnedCallees) = db.RunTest(test['spec'],test['N'])
print 'average randomTime = %f' % (avRandTime)
print 'average queryTime = %f' % (avQueryTime)
print 'longest queryTime = %f' % (longestQueryTime)
print 'average returned callees = %f' % (avReturnedCallees)
print ''
KillDB()
if (__name__ == '__main__'):
main()