This repository has been archived by the owner on May 13, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test script that runs a bunch of queries with AND and OR.
It prints the the results and a summary of the times for the last 10 of 11 trials.
- Loading branch information
Jeremy Hylton
committed
May 15, 2002
1 parent
eb857f0
commit 00afc05
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
from time import clock | ||
|
||
import ZODB | ||
from ZODB.FileStorage import FileStorage | ||
|
||
QUERIES = ["nested recursive functions", | ||
"explicit better than implicit", | ||
"build hpux", | ||
"cannot create 'method-wrapper' instances", | ||
"extension module C++", | ||
"class method", | ||
"instance variable", | ||
"articulate information", | ||
"import default files", | ||
"gopher ftp http", | ||
] | ||
|
||
def main(rt): | ||
index = rt["index"] | ||
files = rt["files"] | ||
times = {} | ||
for i in range(11): | ||
for q in QUERIES: | ||
terms = q.split() | ||
for c in " OR ", " AND ": | ||
query = c.join(terms) | ||
t0 = clock() | ||
results, num = index.query(query) | ||
t1 = clock() | ||
print num, query, t1 - t0 | ||
key = query | ||
if i == 0: | ||
for docid, score in results: | ||
print score, files[docid] | ||
continue | ||
l = times.setdefault(key, []) | ||
l.append(t1 - t0) | ||
|
||
l = times.keys() | ||
l.sort() | ||
for k in l: | ||
v = times[k] | ||
print min(v), k, " ".join(map(str, v)) | ||
|
||
if __name__ == "__main__": | ||
import sys | ||
import getopt | ||
|
||
VERBOSE = 0 | ||
FSPATH = "Data.fs" | ||
|
||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], 'vf:') | ||
except getopt.error, msg: | ||
print msg | ||
print __doc__ | ||
sys.exit(2) | ||
|
||
for o, v in opts: | ||
if o == '-v': | ||
VERBOSE += 1 | ||
if o == '-f': | ||
FSPATH = v | ||
|
||
fs = FileStorage(FSPATH, read_only=1) | ||
db = ZODB.DB(fs) | ||
cn = db.open() | ||
rt = cn.root() | ||
main(rt) | ||
|