made the plotter script dump out both timing and rms info.

This commit is contained in:
Stephen McQuay 2011-05-27 15:06:35 -06:00
parent b38514ff1d
commit 46b6cbb7bb
1 changed files with 60 additions and 16 deletions

View File

@ -1,25 +1,69 @@
import sys
import os
import sqlite3
from interp.tools import rms
import numpy as np
con = sqlite3.connect(sys.argv[1])
cur = con.cursor()
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s [options] <db file>")
parser.add_option("-R", "--resolution",
type="int", dest="res", default=1,
help="resolution (for constant resolution charts) (default: %default)")
parser.add_option("-t", "--time",
action="store_true", dest="time", default=False,
help="write out timing results (default: %default)")
parser.add_option("-T", "--time-by-res",
action="store_true", dest="time", default=False,
help="write out timing (default: %default)")
parser.add_option("-r", "--rms",
action="store_true", dest="rms", default=False,
help="write out rms output (default: %default)")
orders = np.array(cur.execute('select distinct ord from results').fetchall())[:,0]
eps = np.array(cur.execute('select distinct ep from results').fetchall())[:,0]
res = np.array(cur.execute('select distinct res from results').fetchall())[:,0]
print "#", orders, eps
(options, args) = parser.parse_args()
if len(args) != 1:
parser.print_usage()
sys.exit(1)
with open('time.out', 'w') as time_file:
for ep in eps:
time_file.write("%d " % ep)
for order in orders:
cur_results = cur.execute('select time from results where res = 1 and ep = ? and ord = ?',
(int(ep),int(order)))
cur_time = np.array(cur_results.fetchall()).mean()
time_file.write("%e " % cur_time)
time_file.write("\n")
con = sqlite3.connect(args[0])
cur = con.cursor()
print "%e" % np.array(cur.execute('select abs(exact - final) from results').fetchall()).mean()
resolutions = np.array(cur.execute('select distinct res from results').fetchall())[:,0]
orders = np.array(cur.execute('select distinct ord from results').fetchall())[:,0]
extrapoints = np.array(cur.execute('select distinct ep from results').fetchall())[:,0]
print "# i found these resolutions %s, orders: %s, and extra points: %s" % (resolutions, orders, extrapoints)
if options.time:
for ep in extrapoints:
print "%d " % (ep,),
for order in orders:
for res in resolutions:
cur_results = cur.execute('select time from results where res = ? and ep = ? and ord = ?',
(int(res), int(ep),int(order)))
cur_time = np.array(cur_results.fetchall()).mean()
print "%e " % (cur_time,),
print
# print "%e" % np.array(cur.execute('select abs(exact - final) from results').fetchall()).mean()
if options.rms:
for ep in extrapoints:
print "%d " % (ep,),
for order in orders:
for res in resolutions:
cur_results = cur.execute('select abs(exact - final) from results where res = ? and ep = ? and ord = ?',
(int(res), int(ep),int(order)))
cur_time = rms(np.array(cur_results.fetchall()))
print "%e " % (cur_time,),
print