stats.py revision 1621
11049Sbinkertn@umich.edu#!/usr/bin/env python
21049Sbinkertn@umich.edufrom __future__ import division
31318Ssaidi@eecs.umich.eduimport re, sys, math
41049Sbinkertn@umich.edu
51329Ssaidi@eecs.umich.edu
61049Sbinkertn@umich.edudef usage():
71049Sbinkertn@umich.edu    print '''\
81049Sbinkertn@umich.eduUsage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
91331Ssaidi@eecs.umich.edu       [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>]
101331Ssaidi@eecs.umich.edu       <command> [command args]
111331Ssaidi@eecs.umich.edu
121331Ssaidi@eecs.umich.edu       commands    extra parameters   description
131331Ssaidi@eecs.umich.edu       ----------- ------------------ ---------------------------------------
141331Ssaidi@eecs.umich.edu       bins        [regex]            List bins (only matching regex)
151331Ssaidi@eecs.umich.edu       formula     <formula>          Evaluated formula specified
161331Ssaidi@eecs.umich.edu       formulas    [regex]            List formulas (only matching regex)
171331Ssaidi@eecs.umich.edu       runs        none               List all runs in database
181331Ssaidi@eecs.umich.edu       samples     none               List samples present in database
191331Ssaidi@eecs.umich.edu       stability   <pairnum> <stats>  Calculated statistical info about stats
201331Ssaidi@eecs.umich.edu       stat        <regex>            Show stat data (only matching regex)
211331Ssaidi@eecs.umich.edu       stats       [regex]            List all stats (only matching regex)
221596Ssaidi@eecs.umich.edu
231596Ssaidi@eecs.umich.edu       database    <command>          Where command is drop, init, or clean
241596Ssaidi@eecs.umich.edu
251049Sbinkertn@umich.edu''' % sys.argv[0]
261049Sbinkertn@umich.edu    sys.exit(1)
271049Sbinkertn@umich.edu
281049Sbinkertn@umich.edudef getopts(list, flags):
291049Sbinkertn@umich.edu    import getopt
301049Sbinkertn@umich.edu    try:
311049Sbinkertn@umich.edu        opts, args = getopt.getopt(list, flags)
321049Sbinkertn@umich.edu    except getopt.GetoptError:
331049Sbinkertn@umich.edu        usage()
341049Sbinkertn@umich.edu
351049Sbinkertn@umich.edu    return opts, args
361049Sbinkertn@umich.edu
371049Sbinkertn@umich.edudef printval(name, value, invert = False):
381049Sbinkertn@umich.edu    if invert and value != 0.0:
391049Sbinkertn@umich.edu        value = 1 / value
401049Sbinkertn@umich.edu
411049Sbinkertn@umich.edu    if value == (1e300*1e300):
421049Sbinkertn@umich.edu        return
431049Sbinkertn@umich.edu
441049Sbinkertn@umich.edu    if printval.mode == 'G':
451049Sbinkertn@umich.edu        print '%s:    %g' % (name, value)
461049Sbinkertn@umich.edu    elif printval.mode != 'F' and value > 1e6:
471049Sbinkertn@umich.edu        print '%s:    %0.5e' % (name, value)
481049Sbinkertn@umich.edu    else:
491049Sbinkertn@umich.edu        print '%s:    %f' % (name, value)
501049Sbinkertn@umich.edu
511049Sbinkertn@umich.eduprintval.mode = 'G'
521049Sbinkertn@umich.edu
531049Sbinkertn@umich.edudef unique(list):
541049Sbinkertn@umich.edu    set = {}
551049Sbinkertn@umich.edu    map(set.__setitem__, list, [])
561049Sbinkertn@umich.edu    return set.keys()
571049Sbinkertn@umich.edu
581621Sbinkertn@umich.edu#benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
591621Sbinkertn@umich.edu
601621Sbinkertn@umich.edudef graphdata(runs, options, tag, label, value):
611307Sbinkertn@umich.edu    import info
621307Sbinkertn@umich.edu
631307Sbinkertn@umich.edu    bench_system = {
641307Sbinkertn@umich.edu        'm' : 'client',
651307Sbinkertn@umich.edu        's' : 'client',
661307Sbinkertn@umich.edu        'snt' : 'client',
671307Sbinkertn@umich.edu        'nb1' : 'server',
681307Sbinkertn@umich.edu        'nb2' : 'server',
691307Sbinkertn@umich.edu        'nt1' : 'server',
701307Sbinkertn@umich.edu        'nt2' : 'server',
711307Sbinkertn@umich.edu        'w1' : 'server',
721307Sbinkertn@umich.edu        'w2' : 'server',
731307Sbinkertn@umich.edu        'w3' : 'server',
741307Sbinkertn@umich.edu        'w4' : 'server',
751307Sbinkertn@umich.edu        'w1s' : 'server',
761307Sbinkertn@umich.edu        'w2s' : 'server',
771307Sbinkertn@umich.edu        'w3s' : 'server',
781307Sbinkertn@umich.edu        'ns' : 'natbox',
791307Sbinkertn@umich.edu        'nm' : 'natbox',
801307Sbinkertn@umich.edu        'nw1' : 'natbox',
811307Sbinkertn@umich.edu        'nw2' : 'natbox',
821307Sbinkertn@umich.edu        'nw3' : 'natbox'
831307Sbinkertn@umich.edu        }
841307Sbinkertn@umich.edu
851621Sbinkertn@umich.edu    system_configs = {
861621Sbinkertn@umich.edu        's1' : 'Uni 4GHz',
871621Sbinkertn@umich.edu        'm1' : 'Uni 6GHz',
881621Sbinkertn@umich.edu        'f1' : 'Uni 8GHz',
891621Sbinkertn@umich.edu        'q1' : 'Uni 10GHz',
901621Sbinkertn@umich.edu        's2' : 'Dual 4GHz',
911621Sbinkertn@umich.edu        'm2' : 'Dual 6GHz',
921621Sbinkertn@umich.edu        's4' : 'Quad 4GHz',
931621Sbinkertn@umich.edu        'm4' : 'Quad 6GHz' }
941621Sbinkertn@umich.edu
951621Sbinkertn@umich.edu    configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
961621Sbinkertn@umich.edu    benchmarks = [ 'm', 'snt', 'w2', 'nm', 'nw2' ]
971621Sbinkertn@umich.edu    caches = [ '0', '2', '4' ]
981621Sbinkertn@umich.edu
991621Sbinkertn@umich.edu    names = []
1001307Sbinkertn@umich.edu    for bench in benchmarks:
1011307Sbinkertn@umich.edu        if bench_system[bench] != options.system:
1021307Sbinkertn@umich.edu            continue
1031307Sbinkertn@umich.edu
1041621Sbinkertn@umich.edu        for cache in caches:
1051621Sbinkertn@umich.edu            names.append([bench, cache])
1061307Sbinkertn@umich.edu
1071621Sbinkertn@umich.edu    for bench,cache in names:
1081621Sbinkertn@umich.edu        base = '%s.%s' % (bench, cache)
1091621Sbinkertn@umich.edu        fname = 'data/uni.%s.%s.dat' % (tag, base)
1101307Sbinkertn@umich.edu        f = open(fname, 'w')
1111307Sbinkertn@umich.edu        print >>f, '#set TITLE = '
1121307Sbinkertn@umich.edu        print >>f, '#set ylbl = %s' % label
1131307Sbinkertn@umich.edu        #print >>f, '#set sublabels = %s' % ' '.join(configs)
1141307Sbinkertn@umich.edu        print >>f, '#set sublabels = ste hte htd ocm occ ocs'
1151307Sbinkertn@umich.edu
1161621Sbinkertn@umich.edu        for speed in ('s1', 'm1', 'f1', 'q1'):
1171621Sbinkertn@umich.edu            label = system_configs[speed]
1181621Sbinkertn@umich.edu            print >>f, '"%s"' % label,
1191307Sbinkertn@umich.edu            for conf in configs:
1201621Sbinkertn@umich.edu                name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
1211307Sbinkertn@umich.edu                run = info.source.allRunNames[name]
1221307Sbinkertn@umich.edu                info.display_run = run.run;
1231307Sbinkertn@umich.edu                val = float(value)
1241307Sbinkertn@umich.edu                if val == 1e300*1e300:
1251307Sbinkertn@umich.edu                    print >>f, 0.0,
1261307Sbinkertn@umich.edu                else:
1271307Sbinkertn@umich.edu                    print >>f, "%f" % val,
1281307Sbinkertn@umich.edu            print >>f
1291307Sbinkertn@umich.edu        f.close()
1301307Sbinkertn@umich.edu
1311269Sbinkertn@umich.edu    configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
1321621Sbinkertn@umich.edu    benchmarks = [ 'w2']
1331621Sbinkertn@umich.edu    caches = [ '0', '2', '4' ]
1341049Sbinkertn@umich.edu
1351049Sbinkertn@umich.edu    names = []
1361049Sbinkertn@umich.edu    for bench in benchmarks:
1371269Sbinkertn@umich.edu        if bench_system[bench] != options.system:
1381269Sbinkertn@umich.edu            continue
1391269Sbinkertn@umich.edu
1401621Sbinkertn@umich.edu        for cache in caches:
1411621Sbinkertn@umich.edu            names.append([bench, cache])
1421049Sbinkertn@umich.edu
1431621Sbinkertn@umich.edu    for bench,cache in names:
1441621Sbinkertn@umich.edu        base = '%s.%s' % (bench, cache)
1451621Sbinkertn@umich.edu        fname = 'data/mp.%s.%s.dat' % (tag, base)
1461049Sbinkertn@umich.edu        f = open(fname, 'w')
1471307Sbinkertn@umich.edu        print >>f, '#set TITLE = '
1481049Sbinkertn@umich.edu        print >>f, '#set ylbl = %s' % label
1491307Sbinkertn@umich.edu        #print >>f, '#set sublabels = %s' % ' '.join(configs)
1501307Sbinkertn@umich.edu        print >>f, '#set sublabels = ste hte htd ocm occ ocs'
1511049Sbinkertn@umich.edu
1521621Sbinkertn@umich.edu        for speed in ('s2', 'm2', 's4', 'm4'):
1531621Sbinkertn@umich.edu            label = system_configs[speed]
1541621Sbinkertn@umich.edu            print >>f, '"%s"' % label,
1551049Sbinkertn@umich.edu            for conf in configs:
1561621Sbinkertn@umich.edu                name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
1571049Sbinkertn@umich.edu                run = info.source.allRunNames[name]
1581049Sbinkertn@umich.edu                info.display_run = run.run;
1591049Sbinkertn@umich.edu                val = float(value)
1601049Sbinkertn@umich.edu                if val == 1e300*1e300:
1611049Sbinkertn@umich.edu                    print >>f, 0.0,
1621049Sbinkertn@umich.edu                else:
1631049Sbinkertn@umich.edu                    print >>f, "%f" % val,
1641049Sbinkertn@umich.edu            print >>f
1651049Sbinkertn@umich.edu        f.close()
1661049Sbinkertn@umich.edu
1671049Sbinkertn@umich.edudef printdata(runs, value, invert = False):
1681049Sbinkertn@umich.edu    import info
1691049Sbinkertn@umich.edu    for run in runs:
1701049Sbinkertn@umich.edu        info.display_run = run.run;
1711049Sbinkertn@umich.edu        val = float(value)
1721049Sbinkertn@umich.edu        printval(run.name, val)
1731049Sbinkertn@umich.edu
1741049Sbinkertn@umich.educlass CommandException(Exception):
1751049Sbinkertn@umich.edu    pass
1761049Sbinkertn@umich.edu
1771049Sbinkertn@umich.edudef commands(options, command, args):
1781049Sbinkertn@umich.edu    if command == 'database':
1791049Sbinkertn@umich.edu        if len(args) == 0: raise CommandException
1801049Sbinkertn@umich.edu
1811049Sbinkertn@umich.edu        import dbinit
1821049Sbinkertn@umich.edu        mydb = dbinit.MyDB(options)
1831049Sbinkertn@umich.edu
1841049Sbinkertn@umich.edu        if args[0] == 'drop':
1851049Sbinkertn@umich.edu            if len(args) > 2: raise CommandException
1861049Sbinkertn@umich.edu            mydb.admin()
1871049Sbinkertn@umich.edu            mydb.drop()
1881049Sbinkertn@umich.edu            if len(args) == 2 and args[1] == 'init':
1891049Sbinkertn@umich.edu                mydb.create()
1901049Sbinkertn@umich.edu                mydb.connect()
1911049Sbinkertn@umich.edu                mydb.populate()
1921049Sbinkertn@umich.edu            mydb.close()
1931049Sbinkertn@umich.edu            return
1941049Sbinkertn@umich.edu
1951049Sbinkertn@umich.edu        if args[0] == 'init':
1961049Sbinkertn@umich.edu            if len(args) > 1: raise CommandException
1971049Sbinkertn@umich.edu            mydb.admin()
1981049Sbinkertn@umich.edu            mydb.create()
1991049Sbinkertn@umich.edu            mydb.connect()
2001049Sbinkertn@umich.edu            mydb.populate()
2011049Sbinkertn@umich.edu            mydb.close()
2021049Sbinkertn@umich.edu            return
2031049Sbinkertn@umich.edu
2041049Sbinkertn@umich.edu        if args[0] == 'clean':
2051049Sbinkertn@umich.edu            if len(args) > 1: raise CommandException
2061049Sbinkertn@umich.edu            mydb.connect()
2071049Sbinkertn@umich.edu            mydb.clean()
2081049Sbinkertn@umich.edu            return
2091049Sbinkertn@umich.edu
2101049Sbinkertn@umich.edu        raise CommandException
2111049Sbinkertn@umich.edu
2121049Sbinkertn@umich.edu    import db, info
2131049Sbinkertn@umich.edu    info.source = db.Database()
2141049Sbinkertn@umich.edu    info.source.host = options.host
2151049Sbinkertn@umich.edu    info.source.db = options.db
2161049Sbinkertn@umich.edu    info.source.passwd = options.passwd
2171049Sbinkertn@umich.edu    info.source.user = options.user
2181049Sbinkertn@umich.edu    info.source.connect()
2191049Sbinkertn@umich.edu    info.source.update_dict(globals())
2201049Sbinkertn@umich.edu
2211049Sbinkertn@umich.edu    if type(options.get) is str:
2221049Sbinkertn@umich.edu        info.source.get = options.get
2231049Sbinkertn@umich.edu
2241049Sbinkertn@umich.edu    if options.runs is None:
2251049Sbinkertn@umich.edu        runs = info.source.allRuns
2261049Sbinkertn@umich.edu    else:
2271049Sbinkertn@umich.edu        rx = re.compile(options.runs)
2281049Sbinkertn@umich.edu        runs = []
2291049Sbinkertn@umich.edu        for run in info.source.allRuns:
2301049Sbinkertn@umich.edu            if rx.match(run.name):
2311049Sbinkertn@umich.edu                runs.append(run)
2321049Sbinkertn@umich.edu
2331049Sbinkertn@umich.edu    info.display_run = runs[0].run
2341049Sbinkertn@umich.edu
2351049Sbinkertn@umich.edu    if command == 'runs':
2361049Sbinkertn@umich.edu        user = None
2371049Sbinkertn@umich.edu        opts, args = getopts(args, '-u')
2381049Sbinkertn@umich.edu        if len(args):
2391049Sbinkertn@umich.edu            raise CommandException
2401049Sbinkertn@umich.edu        for o,a in opts:
2411049Sbinkertn@umich.edu            if o == '-u':
2421049Sbinkertn@umich.edu                user = a
2431049Sbinkertn@umich.edu        info.source.listRuns(user)
2441049Sbinkertn@umich.edu        return
2451049Sbinkertn@umich.edu
2461309Ssaidi@eecs.umich.edu    if command == 'stability':
2471331Ssaidi@eecs.umich.edu        if len(args) < 2:
2481331Ssaidi@eecs.umich.edu            raise CommandException
2491331Ssaidi@eecs.umich.edu
2501331Ssaidi@eecs.umich.edu        try:
2511331Ssaidi@eecs.umich.edu            merge = int(args[0])
2521331Ssaidi@eecs.umich.edu        except ValueError:
2531331Ssaidi@eecs.umich.edu            usage()
2541331Ssaidi@eecs.umich.edu        stats = info.source.getStat(args[1])
2551331Ssaidi@eecs.umich.edu        info.source.get = "sum"
2561331Ssaidi@eecs.umich.edu
2571309Ssaidi@eecs.umich.edu
2581309Ssaidi@eecs.umich.edu        #loop through all the stats selected
2591309Ssaidi@eecs.umich.edu        for stat in stats:
2601309Ssaidi@eecs.umich.edu
2611317Ssaidi@eecs.umich.edu            print "%s:" % stat.name
2621331Ssaidi@eecs.umich.edu            print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
2631329Ssaidi@eecs.umich.edu                  ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV")
2641331Ssaidi@eecs.umich.edu            print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
2651329Ssaidi@eecs.umich.edu                  ("--------------------", "------------",
2661331Ssaidi@eecs.umich.edu                   "------------", "----", "-----", "-----", "-----", "----------")
2671309Ssaidi@eecs.umich.edu            #loop through all the selected runs
2681309Ssaidi@eecs.umich.edu            for run in runs:
2691309Ssaidi@eecs.umich.edu                info.display_run = run.run;
2701309Ssaidi@eecs.umich.edu                runTicks = info.source.retTicks([ run ])
2711309Ssaidi@eecs.umich.edu                #throw away the first one, it's 0
2721309Ssaidi@eecs.umich.edu                runTicks.pop(0)
2731329Ssaidi@eecs.umich.edu                info.globalTicks = runTicks
2741331Ssaidi@eecs.umich.edu                avg = 0
2751317Ssaidi@eecs.umich.edu                stdev = 0
2761317Ssaidi@eecs.umich.edu                numoutsideavg  = 0
2771318Ssaidi@eecs.umich.edu                numoutside1std = 0
2781318Ssaidi@eecs.umich.edu                numoutside2std = 0
2791331Ssaidi@eecs.umich.edu                pairRunTicks = []
2801331Ssaidi@eecs.umich.edu                if float(stat) == 1e300*1e300:
2811331Ssaidi@eecs.umich.edu                    continue
2821331Ssaidi@eecs.umich.edu                for t in range(0, len(runTicks)-(merge-1), merge):
2831331Ssaidi@eecs.umich.edu                    tempPair = []
2841331Ssaidi@eecs.umich.edu                    for p in range(0,merge):
2851331Ssaidi@eecs.umich.edu                        tempPair.append(runTicks[t+p])
2861331Ssaidi@eecs.umich.edu                    pairRunTicks.append(tempPair)
2871309Ssaidi@eecs.umich.edu                #loop through all the various ticks for each run
2881331Ssaidi@eecs.umich.edu                for tick in pairRunTicks:
2891331Ssaidi@eecs.umich.edu                    info.globalTicks = tick
2901331Ssaidi@eecs.umich.edu                    avg += float(stat)
2911331Ssaidi@eecs.umich.edu                avg /= len(pairRunTicks)
2921331Ssaidi@eecs.umich.edu                for tick in pairRunTicks:
2931331Ssaidi@eecs.umich.edu                    info.globalTicks = tick
2941331Ssaidi@eecs.umich.edu                    val = float(stat)
2951331Ssaidi@eecs.umich.edu                    stdev += pow((val-avg),2)
2961331Ssaidi@eecs.umich.edu                stdev = math.sqrt(stdev / len(pairRunTicks))
2971331Ssaidi@eecs.umich.edu                for tick in pairRunTicks:
2981331Ssaidi@eecs.umich.edu                    info.globalTicks = tick
2991309Ssaidi@eecs.umich.edu                    val = float(stat)
3001309Ssaidi@eecs.umich.edu                    if (val < (avg * .9)) or (val > (avg * 1.1)):
3011317Ssaidi@eecs.umich.edu                        numoutsideavg += 1
3021317Ssaidi@eecs.umich.edu                    if (val < (avg - stdev)) or (val > (avg + stdev)):
3031318Ssaidi@eecs.umich.edu                        numoutside1std += 1
3041318Ssaidi@eecs.umich.edu                    if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))):
3051318Ssaidi@eecs.umich.edu                        numoutside2std += 1
3061331Ssaidi@eecs.umich.edu                if avg > 1000:
3071331Ssaidi@eecs.umich.edu                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
3081331Ssaidi@eecs.umich.edu                          (run.name, "%.1f" % avg, "%.1f" % stdev,
3091331Ssaidi@eecs.umich.edu                           "%d" % numoutsideavg, "%d" % numoutside1std,
3101331Ssaidi@eecs.umich.edu                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
3111331Ssaidi@eecs.umich.edu                           "%.3f" % (stdev/avg*100))
3121331Ssaidi@eecs.umich.edu                elif avg > 100:
3131331Ssaidi@eecs.umich.edu                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
3141331Ssaidi@eecs.umich.edu                          (run.name, "%.1f" % avg, "%.1f" % stdev,
3151331Ssaidi@eecs.umich.edu                           "%d" % numoutsideavg, "%d" % numoutside1std,
3161331Ssaidi@eecs.umich.edu                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
3171331Ssaidi@eecs.umich.edu                           "%.5f" % (stdev/avg*100))
3181331Ssaidi@eecs.umich.edu                else:
3191331Ssaidi@eecs.umich.edu                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
3201331Ssaidi@eecs.umich.edu                          (run.name, "%.5f" % avg, "%.5f" % stdev,
3211331Ssaidi@eecs.umich.edu                           "%d" % numoutsideavg, "%d" % numoutside1std,
3221331Ssaidi@eecs.umich.edu                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
3231331Ssaidi@eecs.umich.edu                           "%.7f" % (stdev/avg*100))
3241309Ssaidi@eecs.umich.edu        return
3251309Ssaidi@eecs.umich.edu
3261049Sbinkertn@umich.edu    if command == 'stats':
3271049Sbinkertn@umich.edu        if len(args) == 0:
3281049Sbinkertn@umich.edu            info.source.listStats()
3291049Sbinkertn@umich.edu        elif len(args) == 1:
3301049Sbinkertn@umich.edu            info.source.listStats(args[0])
3311049Sbinkertn@umich.edu        else:
3321049Sbinkertn@umich.edu            raise CommandException
3331049Sbinkertn@umich.edu
3341049Sbinkertn@umich.edu        return
3351049Sbinkertn@umich.edu
3361049Sbinkertn@umich.edu    if command == 'stat':
3371049Sbinkertn@umich.edu        if len(args) != 1:
3381049Sbinkertn@umich.edu            raise CommandException
3391049Sbinkertn@umich.edu
3401049Sbinkertn@umich.edu        stats = info.source.getStat(args[0])
3411049Sbinkertn@umich.edu        for stat in stats:
3421076Sbinkertn@umich.edu            if options.graph:
3431269Sbinkertn@umich.edu                graphdata(runs, options, stat.name, stat.name, stat)
3441049Sbinkertn@umich.edu            else:
3451301Ssaidi@eecs.umich.edu                if options.ticks:
3461301Ssaidi@eecs.umich.edu                   print 'only displaying sample %s' % options.ticks
3471329Ssaidi@eecs.umich.edu                   info.globalTicks = [ int(x) for x in options.ticks.split() ]
3481301Ssaidi@eecs.umich.edu
3491165Sbinkertn@umich.edu                if options.binned:
3501165Sbinkertn@umich.edu                    print 'kernel ticks'
3511165Sbinkertn@umich.edu                    stat.bins = 'kernel'
3521165Sbinkertn@umich.edu                    printdata(runs, stat)
3531165Sbinkertn@umich.edu
3541165Sbinkertn@umich.edu                    print 'idle ticks'
3551165Sbinkertn@umich.edu                    stat.bins = 'idle'
3561165Sbinkertn@umich.edu                    printdata(runs, stat)
3571165Sbinkertn@umich.edu
3581165Sbinkertn@umich.edu                    print 'user ticks'
3591165Sbinkertn@umich.edu                    stat.bins = 'user'
3601165Sbinkertn@umich.edu                    printdata(runs, stat)
3611165Sbinkertn@umich.edu
3621165Sbinkertn@umich.edu                    print 'interrupt ticks'
3631301Ssaidi@eecs.umich.edu                    stat.bins = 'interrupt'
3641165Sbinkertn@umich.edu                    printdata(runs, stat)
3651165Sbinkertn@umich.edu
3661165Sbinkertn@umich.edu                    print 'total ticks'
3671165Sbinkertn@umich.edu
3681165Sbinkertn@umich.edu                stat.bins = None
3691049Sbinkertn@umich.edu                print stat.name
3701049Sbinkertn@umich.edu                printdata(runs, stat)
3711049Sbinkertn@umich.edu        return
3721049Sbinkertn@umich.edu
3731269Sbinkertn@umich.edu    if command == 'formula':
3741269Sbinkertn@umich.edu        if len(args) != 1:
3751269Sbinkertn@umich.edu            raise CommandException
3761269Sbinkertn@umich.edu
3771269Sbinkertn@umich.edu        stats = eval(args[0])
3781269Sbinkertn@umich.edu        for stat in stats:
3791269Sbinkertn@umich.edu            if options.graph:
3801269Sbinkertn@umich.edu                graphdata(runs, options, stat.name, stat.name, stat)
3811269Sbinkertn@umich.edu            else:
3821269Sbinkertn@umich.edu                if options.binned:
3831269Sbinkertn@umich.edu                    print 'kernel ticks'
3841269Sbinkertn@umich.edu                    stat.bins = 'kernel'
3851269Sbinkertn@umich.edu                    printdata(runs, stat)
3861269Sbinkertn@umich.edu
3871269Sbinkertn@umich.edu                    print 'idle ticks'
3881269Sbinkertn@umich.edu                    stat.bins = 'idle'
3891269Sbinkertn@umich.edu                    printdata(runs, stat)
3901269Sbinkertn@umich.edu
3911269Sbinkertn@umich.edu                    print 'user ticks'
3921269Sbinkertn@umich.edu                    stat.bins = 'user'
3931269Sbinkertn@umich.edu                    printdata(runs, stat)
3941269Sbinkertn@umich.edu
3951269Sbinkertn@umich.edu                    print 'interrupt ticks'
3961301Ssaidi@eecs.umich.edu                    stat.bins = 'interrupt'
3971269Sbinkertn@umich.edu                    printdata(runs, stat)
3981269Sbinkertn@umich.edu
3991269Sbinkertn@umich.edu                    print 'total ticks'
4001269Sbinkertn@umich.edu
4011269Sbinkertn@umich.edu                stat.bins = None
4021269Sbinkertn@umich.edu                print args[0]
4031269Sbinkertn@umich.edu                printdata(runs, stat)
4041269Sbinkertn@umich.edu        return
4051269Sbinkertn@umich.edu
4061049Sbinkertn@umich.edu    if command == 'bins':
4071049Sbinkertn@umich.edu        if len(args) == 0:
4081049Sbinkertn@umich.edu            info.source.listBins()
4091049Sbinkertn@umich.edu        elif len(args) == 1:
4101049Sbinkertn@umich.edu            info.source.listBins(args[0])
4111049Sbinkertn@umich.edu        else:
4121049Sbinkertn@umich.edu            raise CommandException
4131049Sbinkertn@umich.edu
4141049Sbinkertn@umich.edu        return
4151049Sbinkertn@umich.edu
4161049Sbinkertn@umich.edu    if command == 'formulas':
4171049Sbinkertn@umich.edu        if len(args) == 0:
4181049Sbinkertn@umich.edu            info.source.listFormulas()
4191049Sbinkertn@umich.edu        elif len(args) == 1:
4201049Sbinkertn@umich.edu            info.source.listFormulas(args[0])
4211049Sbinkertn@umich.edu        else:
4221049Sbinkertn@umich.edu            raise CommandException
4231049Sbinkertn@umich.edu
4241049Sbinkertn@umich.edu        return
4251049Sbinkertn@umich.edu
4261049Sbinkertn@umich.edu    if command == 'samples':
4271049Sbinkertn@umich.edu        if len(args):
4281049Sbinkertn@umich.edu            raise CommandException
4291049Sbinkertn@umich.edu
4301049Sbinkertn@umich.edu        info.source.listTicks(runs)
4311049Sbinkertn@umich.edu        return
4321049Sbinkertn@umich.edu
4331049Sbinkertn@umich.edu    if len(args):
4341049Sbinkertn@umich.edu        raise CommandException
4351049Sbinkertn@umich.edu
4361209Sbinkertn@umich.edu    system = info.source.__dict__[options.system]
4371209Sbinkertn@umich.edu
4381049Sbinkertn@umich.edu    if command == 'usertime':
4391049Sbinkertn@umich.edu        import copy
4401604Srdreslin@umich.edu        kernel = copy.copy(system.full0.numCycles)
4411049Sbinkertn@umich.edu        kernel.bins = 'kernel'
4421049Sbinkertn@umich.edu
4431604Srdreslin@umich.edu        user = copy.copy(system.full0.numCycles)
4441049Sbinkertn@umich.edu        user.bins = 'user'
4451049Sbinkertn@umich.edu
4461076Sbinkertn@umich.edu        if options.graph:
4471269Sbinkertn@umich.edu            graphdata(runs, options, 'usertime', 'User Fraction',
4481604Srdreslin@umich.edu                      user / system.full0.numCycles)
4491049Sbinkertn@umich.edu        else:
4501604Srdreslin@umich.edu            printdata(runs, user / system.full0.numCycles)
4511049Sbinkertn@umich.edu        return
4521049Sbinkertn@umich.edu
4531049Sbinkertn@umich.edu    if command == 'ticks':
4541076Sbinkertn@umich.edu        if options.binned:
4551049Sbinkertn@umich.edu            print 'kernel ticks'
4561604Srdreslin@umich.edu            system.full0.numCycles.bins = 'kernel'
4571604Srdreslin@umich.edu            printdata(runs, system.full0.numCycles)
4581049Sbinkertn@umich.edu
4591049Sbinkertn@umich.edu            print 'idle ticks'
4601604Srdreslin@umich.edu            system.full0.numCycles.bins = 'idle'
4611604Srdreslin@umich.edu            printdata(runs, system.full0.numCycles)
4621049Sbinkertn@umich.edu
4631049Sbinkertn@umich.edu            print 'user ticks'
4641604Srdreslin@umich.edu            system.full0.numCycles.bins = 'user'
4651604Srdreslin@umich.edu            printdata(runs, system.full0.numCycles)
4661049Sbinkertn@umich.edu
4671049Sbinkertn@umich.edu            print 'total ticks'
4681049Sbinkertn@umich.edu
4691604Srdreslin@umich.edu        system.full0.numCycles.bins = None
4701604Srdreslin@umich.edu        printdata(runs, system.full0.numCycles)
4711049Sbinkertn@umich.edu        return
4721049Sbinkertn@umich.edu
4731049Sbinkertn@umich.edu    if command == 'packets':
4741604Srdreslin@umich.edu        packets = system.tsunami.etherdev0.rxPackets
4751076Sbinkertn@umich.edu        if options.graph:
4761269Sbinkertn@umich.edu            graphdata(runs, options, 'packets', 'Packets', packets)
4771049Sbinkertn@umich.edu        else:
4781049Sbinkertn@umich.edu            printdata(runs, packets)
4791049Sbinkertn@umich.edu        return
4801049Sbinkertn@umich.edu
4811049Sbinkertn@umich.edu    if command == 'ppt' or command == 'tpp':
4821604Srdreslin@umich.edu        ppt = system.tsunami.etherdev0.rxPackets / sim_ticks
4831049Sbinkertn@umich.edu        printdata(runs, ppt, command == 'tpp')
4841049Sbinkertn@umich.edu        return
4851049Sbinkertn@umich.edu
4861049Sbinkertn@umich.edu    if command == 'pps':
4871604Srdreslin@umich.edu        pps = system.tsunami.etherdev0.rxPackets / sim_seconds
4881076Sbinkertn@umich.edu        if options.graph:
4891269Sbinkertn@umich.edu            graphdata(runs, options, 'pps', 'Packets/s', pps)
4901049Sbinkertn@umich.edu        else:
4911049Sbinkertn@umich.edu            printdata(runs, pps)
4921049Sbinkertn@umich.edu        return
4931049Sbinkertn@umich.edu
4941049Sbinkertn@umich.edu    if command == 'bpt' or command == 'tpb':
4951604Srdreslin@umich.edu        bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
4961049Sbinkertn@umich.edu        bpt = bytes / sim_ticks * 8
4971076Sbinkertn@umich.edu        if options.graph:
4981269Sbinkertn@umich.edu            graphdata(runs, options, 'bpt', 'bps / Hz', bpt)
4991049Sbinkertn@umich.edu        else:
5001049Sbinkertn@umich.edu            printdata(runs, bpt, command == 'tpb')
5011049Sbinkertn@umich.edu        return
5021049Sbinkertn@umich.edu
5031049Sbinkertn@umich.edu    if command == 'bptb' or command == 'tpbb':
5041604Srdreslin@umich.edu        bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
5051049Sbinkertn@umich.edu
5061049Sbinkertn@umich.edu        print 'kernel stats'
5071049Sbinkertn@umich.edu        bytes.bins = 'kernel'
5081049Sbinkertn@umich.edu        printdata(runs, bytes / ticks)
5091049Sbinkertn@umich.edu
5101049Sbinkertn@umich.edu        print 'idle stats'
5111049Sbinkertn@umich.edu        bytes.bins = 'idle'
5121049Sbinkertn@umich.edu        printdata(runs, bytes / ticks)
5131049Sbinkertn@umich.edu
5141049Sbinkertn@umich.edu        print 'user stats'
5151049Sbinkertn@umich.edu        bytes.bins = 'user'
5161049Sbinkertn@umich.edu        printdata(runs, bytes / ticks)
5171049Sbinkertn@umich.edu
5181049Sbinkertn@umich.edu        return
5191049Sbinkertn@umich.edu
5201049Sbinkertn@umich.edu    if command == 'bytes':
5211604Srdreslin@umich.edu        stat = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
5221049Sbinkertn@umich.edu
5231076Sbinkertn@umich.edu        if options.binned:
5241049Sbinkertn@umich.edu            print '%s kernel stats' % stat.name
5251049Sbinkertn@umich.edu            stat.bins = 'kernel'
5261049Sbinkertn@umich.edu            printdata(runs, stat)
5271049Sbinkertn@umich.edu
5281049Sbinkertn@umich.edu            print '%s idle stats' % stat.name
5291049Sbinkertn@umich.edu            stat.bins = 'idle'
5301049Sbinkertn@umich.edu            printdata(runs, stat)
5311049Sbinkertn@umich.edu
5321049Sbinkertn@umich.edu            print '%s user stats' % stat.name
5331049Sbinkertn@umich.edu            stat.bins = 'user'
5341049Sbinkertn@umich.edu            printdata(runs, stat)
5351049Sbinkertn@umich.edu
5361049Sbinkertn@umich.edu            print '%s total stats' % stat.name
5371049Sbinkertn@umich.edu            stat.bins = None
5381049Sbinkertn@umich.edu
5391049Sbinkertn@umich.edu        printdata(runs, stat)
5401049Sbinkertn@umich.edu        return
5411049Sbinkertn@umich.edu
5421049Sbinkertn@umich.edu    if command == 'rxbps':
5431604Srdreslin@umich.edu        gbps = system.tsunami.etherdev0.rxBandwidth / 1e9
5441076Sbinkertn@umich.edu        if options.graph:
5451269Sbinkertn@umich.edu            graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)',  gbps)
5461049Sbinkertn@umich.edu        else:
5471049Sbinkertn@umich.edu            printdata(runs, gbps)
5481049Sbinkertn@umich.edu        return
5491049Sbinkertn@umich.edu
5501049Sbinkertn@umich.edu    if command == 'txbps':
5511604Srdreslin@umich.edu        gbps = system.tsunami.etherdev0.txBandwidth / 1e9
5521076Sbinkertn@umich.edu        if options.graph:
5531269Sbinkertn@umich.edu            graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)',  gbps)
5541049Sbinkertn@umich.edu        else:
5551049Sbinkertn@umich.edu            printdata(runs, gbps)
5561049Sbinkertn@umich.edu        return
5571049Sbinkertn@umich.edu
5581049Sbinkertn@umich.edu    if command == 'bps':
5591604Srdreslin@umich.edu        rxbps = system.tsunami.etherdev0.rxBandwidth
5601604Srdreslin@umich.edu        txbps = system.tsunami.etherdev0.txBandwidth
5611049Sbinkertn@umich.edu        gbps = (rxbps + txbps) / 1e9
5621076Sbinkertn@umich.edu        if options.graph:
5631269Sbinkertn@umich.edu            graphdata(runs, options, 'bps', 'Bandwidth (Gbps)',  gbps)
5641049Sbinkertn@umich.edu        else:
5651049Sbinkertn@umich.edu            printdata(runs, gbps)
5661049Sbinkertn@umich.edu        return
5671049Sbinkertn@umich.edu
5681049Sbinkertn@umich.edu    if command == 'misses':
5691604Srdreslin@umich.edu        stat = system.l2.overall_mshr_misses
5701076Sbinkertn@umich.edu        if options.binned:
5711049Sbinkertn@umich.edu            print '%s kernel stats' % stat.name
5721049Sbinkertn@umich.edu            stat.bins = 'kernel'
5731049Sbinkertn@umich.edu            printdata(runs, stat)
5741049Sbinkertn@umich.edu
5751049Sbinkertn@umich.edu            print '%s idle stats' % stat.name
5761049Sbinkertn@umich.edu            stat.bins = 'idle'
5771049Sbinkertn@umich.edu            printdata(runs, stat)
5781049Sbinkertn@umich.edu
5791049Sbinkertn@umich.edu            print '%s user stats' % stat.name
5801049Sbinkertn@umich.edu            stat.bins = 'user'
5811049Sbinkertn@umich.edu            printdata(runs, stat)
5821049Sbinkertn@umich.edu
5831049Sbinkertn@umich.edu            print '%s total stats' % stat.name
5841049Sbinkertn@umich.edu
5851049Sbinkertn@umich.edu        stat.bins = None
5861076Sbinkertn@umich.edu        if options.graph:
5871269Sbinkertn@umich.edu            graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat)
5881049Sbinkertn@umich.edu        else:
5891049Sbinkertn@umich.edu            printdata(runs, stat)
5901049Sbinkertn@umich.edu        return
5911049Sbinkertn@umich.edu
5921049Sbinkertn@umich.edu    if command == 'mpkb':
5931604Srdreslin@umich.edu        misses = system.l2.overall_mshr_misses
5941604Srdreslin@umich.edu        rxbytes = system.tsunami.etherdev0.rxBytes
5951604Srdreslin@umich.edu        txbytes = system.tsunami.etherdev0.txBytes
5961049Sbinkertn@umich.edu
5971076Sbinkertn@umich.edu        if options.binned:
5981049Sbinkertn@umich.edu            print 'mpkb kernel stats'
5991049Sbinkertn@umich.edu            misses.bins = 'kernel'
6001049Sbinkertn@umich.edu            mpkb = misses / ((rxbytes + txbytes) / 1024)
6011049Sbinkertn@umich.edu            printdata(runs, mpkb)
6021049Sbinkertn@umich.edu
6031049Sbinkertn@umich.edu            print 'mpkb idle stats'
6041049Sbinkertn@umich.edu            misses.bins = 'idle'
6051049Sbinkertn@umich.edu            mpkb = misses / ((rxbytes + txbytes) / 1024)
6061049Sbinkertn@umich.edu            printdata(runs, mpkb)
6071049Sbinkertn@umich.edu
6081049Sbinkertn@umich.edu            print 'mpkb user stats'
6091049Sbinkertn@umich.edu            misses.bins = 'user'
6101049Sbinkertn@umich.edu            mpkb = misses / ((rxbytes + txbytes) / 1024)
6111049Sbinkertn@umich.edu            printdata(runs, mpkb)
6121049Sbinkertn@umich.edu
6131049Sbinkertn@umich.edu            print 'mpkb total stats'
6141049Sbinkertn@umich.edu
6151049Sbinkertn@umich.edu        mpkb = misses / ((rxbytes + txbytes) / 1024)
6161049Sbinkertn@umich.edu        misses.bins = None
6171076Sbinkertn@umich.edu        if options.graph:
6181269Sbinkertn@umich.edu            graphdata(runs, options, 'mpkb', 'Misses / KB',  mpkb)
6191049Sbinkertn@umich.edu        else:
6201049Sbinkertn@umich.edu            printdata(runs, mpkb)
6211049Sbinkertn@umich.edu        return
6221049Sbinkertn@umich.edu
6231269Sbinkertn@umich.edu    if command == 'ipkb':
6241604Srdreslin@umich.edu        interrupts = system.full0.kern.faults[4]
6251604Srdreslin@umich.edu        rxbytes = system.tsunami.etherdev0.rxBytes
6261604Srdreslin@umich.edu        txbytes = system.tsunami.etherdev0.txBytes
6271269Sbinkertn@umich.edu
6281269Sbinkertn@umich.edu        if options.binned:
6291269Sbinkertn@umich.edu            print 'ipkb kernel stats'
6301269Sbinkertn@umich.edu            interrupts.bins = 'kernel'
6311269Sbinkertn@umich.edu            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
6321269Sbinkertn@umich.edu            printdata(runs, ipkb)
6331269Sbinkertn@umich.edu
6341269Sbinkertn@umich.edu            print 'ipkb idle stats'
6351269Sbinkertn@umich.edu            interrupts.bins = 'idle'
6361269Sbinkertn@umich.edu            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
6371269Sbinkertn@umich.edu            printdata(runs, ipkb)
6381269Sbinkertn@umich.edu
6391269Sbinkertn@umich.edu            print 'ipkb user stats'
6401269Sbinkertn@umich.edu            interrupts.bins = 'user'
6411269Sbinkertn@umich.edu            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
6421269Sbinkertn@umich.edu            printdata(runs, ipkb)
6431269Sbinkertn@umich.edu
6441269Sbinkertn@umich.edu            print 'ipkb total stats'
6451269Sbinkertn@umich.edu
6461269Sbinkertn@umich.edu        ipkb = interrupts / ((rxbytes + txbytes) / 1024)
6471269Sbinkertn@umich.edu        interrupts.bins = None
6481269Sbinkertn@umich.edu        if options.graph:
6491269Sbinkertn@umich.edu            graphdata(runs, options, 'ipkb', 'Interrupts / KB',  ipkb)
6501269Sbinkertn@umich.edu        else:
6511269Sbinkertn@umich.edu            printdata(runs, ipkb)
6521269Sbinkertn@umich.edu        return
6531269Sbinkertn@umich.edu
6541049Sbinkertn@umich.edu    if command == 'execute':
6551604Srdreslin@umich.edu        printdata(runs, system.full0.ISSUE__count)
6561049Sbinkertn@umich.edu        return
6571049Sbinkertn@umich.edu
6581049Sbinkertn@umich.edu    if command == 'commit':
6591604Srdreslin@umich.edu        printdata(runs, system.full0.COM__count)
6601049Sbinkertn@umich.edu        return
6611049Sbinkertn@umich.edu
6621049Sbinkertn@umich.edu    if command == 'fetch':
6631604Srdreslin@umich.edu        printdata(runs, system.full0.FETCH__count)
6641049Sbinkertn@umich.edu        return
6651049Sbinkertn@umich.edu
6661162Sbinkertn@umich.edu    if command == 'bpp':
6671604Srdreslin@umich.edu        ed = system.tsunami.etherdev0
6681162Sbinkertn@umich.edu        bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets)
6691162Sbinkertn@umich.edu        if options.graph:
6701269Sbinkertn@umich.edu            graphdata(runs, options, 'bpp', 'Bytes / Packet',  bpp)
6711162Sbinkertn@umich.edu        else:
6721162Sbinkertn@umich.edu            printdata(runs, bpp)
6731162Sbinkertn@umich.edu        return
6741162Sbinkertn@umich.edu
6751049Sbinkertn@umich.edu    if command == 'rxbpp':
6761604Srdreslin@umich.edu        bpp = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.rxPackets
6771162Sbinkertn@umich.edu        if options.graph:
6781269Sbinkertn@umich.edu            graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet',  bpp)
6791162Sbinkertn@umich.edu        else:
6801162Sbinkertn@umich.edu            printdata(runs, bpp)
6811049Sbinkertn@umich.edu        return
6821049Sbinkertn@umich.edu
6831049Sbinkertn@umich.edu    if command == 'txbpp':
6841604Srdreslin@umich.edu        bpp = system.tsunami.etherdev0.txBytes / system.tsunami.etherdev0.txPackets
6851162Sbinkertn@umich.edu        if options.graph:
6861269Sbinkertn@umich.edu            graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet',  bpp)
6871162Sbinkertn@umich.edu        else:
6881162Sbinkertn@umich.edu            printdata(runs, bpp)
6891162Sbinkertn@umich.edu        return
6901162Sbinkertn@umich.edu
6911162Sbinkertn@umich.edu    if command == 'rtp':
6921604Srdreslin@umich.edu        rtp = system.tsunami.etherdev0.rxPackets / system.tsunami.etherdev0.txPackets
6931162Sbinkertn@umich.edu        if options.graph:
6941269Sbinkertn@umich.edu            graphdata(runs, options, 'rtp', 'rxPackets / txPackets',  rtp)
6951162Sbinkertn@umich.edu        else:
6961162Sbinkertn@umich.edu            printdata(runs, rtp)
6971162Sbinkertn@umich.edu        return
6981162Sbinkertn@umich.edu
6991162Sbinkertn@umich.edu    if command == 'rtb':
7001604Srdreslin@umich.edu        rtb = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.txBytes
7011162Sbinkertn@umich.edu        if options.graph:
7021269Sbinkertn@umich.edu            graphdata(runs, options, 'rtb', 'rxBytes / txBytes',  rtb)
7031162Sbinkertn@umich.edu        else:
7041162Sbinkertn@umich.edu            printdata(runs, rtb)
7051049Sbinkertn@umich.edu        return
7061049Sbinkertn@umich.edu
7071049Sbinkertn@umich.edu    raise CommandException
7081049Sbinkertn@umich.edu
7091049Sbinkertn@umich.edu
7101049Sbinkertn@umich.educlass Options: pass
7111049Sbinkertn@umich.edu
7121049Sbinkertn@umich.eduif __name__ == '__main__':
7131049Sbinkertn@umich.edu    import getpass
7141049Sbinkertn@umich.edu
7151049Sbinkertn@umich.edu    options = Options()
7161049Sbinkertn@umich.edu    options.host = 'zizzer.pool'
7171049Sbinkertn@umich.edu    options.db = None
7181049Sbinkertn@umich.edu    options.passwd = ''
7191049Sbinkertn@umich.edu    options.user = getpass.getuser()
7201049Sbinkertn@umich.edu    options.runs = None
7211049Sbinkertn@umich.edu    options.system = 'client'
7221049Sbinkertn@umich.edu    options.get = None
7231076Sbinkertn@umich.edu    options.binned = False
7241076Sbinkertn@umich.edu    options.graph = False
7251301Ssaidi@eecs.umich.edu    options.ticks = False
7261049Sbinkertn@umich.edu
7271308Ssaidi@eecs.umich.edu    opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:')
7281049Sbinkertn@umich.edu    for o,a in opts:
7291049Sbinkertn@umich.edu        if o == '-B':
7301049Sbinkertn@umich.edu            options.binned = True
7311049Sbinkertn@umich.edu        if o == '-E':
7321049Sbinkertn@umich.edu            printval.mode = 'E'
7331049Sbinkertn@umich.edu        if o == '-F':
7341049Sbinkertn@umich.edu            printval.mode = 'F'
7351049Sbinkertn@umich.edu        if o == '-G':
7361049Sbinkertn@umich.edu            options.graph = True;
7371049Sbinkertn@umich.edu        if o == '-d':
7381049Sbinkertn@umich.edu            options.db = a
7391049Sbinkertn@umich.edu        if o == '-g':
7401049Sbinkertn@umich.edu            options.get = a
7411049Sbinkertn@umich.edu        if o == '-h':
7421049Sbinkertn@umich.edu            options.host = a
7431049Sbinkertn@umich.edu        if o == '-p':
7441049Sbinkertn@umich.edu            options.passwd = getpass.getpass()
7451049Sbinkertn@umich.edu        if o == '-r':
7461049Sbinkertn@umich.edu            options.runs = a
7471049Sbinkertn@umich.edu        if o == '-u':
7481049Sbinkertn@umich.edu            options.user = a
7491049Sbinkertn@umich.edu        if o == '-s':
7501049Sbinkertn@umich.edu            options.system = a
7511301Ssaidi@eecs.umich.edu        if o == '-T':
7521301Ssaidi@eecs.umich.edu            options.ticks = a
7531049Sbinkertn@umich.edu
7541049Sbinkertn@umich.edu    if len(args) == 0:
7551049Sbinkertn@umich.edu        usage()
7561049Sbinkertn@umich.edu
7571049Sbinkertn@umich.edu    command = args[0]
7581049Sbinkertn@umich.edu    args = args[1:]
7591049Sbinkertn@umich.edu
7601049Sbinkertn@umich.edu    try:
7611049Sbinkertn@umich.edu        commands(options, command, args)
7621049Sbinkertn@umich.edu    except CommandException:
7631049Sbinkertn@umich.edu        usage()
764