summaryrefslogtreecommitdiff
path: root/util/stats/stats.py
blob: eedb006a005809396174a62b6f646ab1ab270f9f (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
#!/usr/bin/env python
from __future__ import division
import re, sys, math


def usage():
    print '''\
Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
       [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>]
       <command> [command args]

       commands    extra parameters   description
       ----------- ------------------ ---------------------------------------
       bins        [regex]            List bins (only matching regex)
       formula     <formula>          Evaluated formula specified
       formulas    [regex]            List formulas (only matching regex)
       runs        none               List all runs in database
       samples     none               List samples present in database
       stability   <pairnum> <stats>  Calculated statistical info about stats
       stat        <regex>            Show stat data (only matching regex)
       stats       [regex]            List all stats (only matching regex)

       database    <command>          Where command is drop, init, or clean

''' % sys.argv[0]
    sys.exit(1)

def getopts(list, flags):
    import getopt
    try:
        opts, args = getopt.getopt(list, flags)
    except getopt.GetoptError:
        usage()

    return opts, args

def printval(name, value, invert = False):
    if invert and value != 0.0:
        value = 1 / value

    if value == (1e300*1e300):
        return

    if printval.mode == 'G':
        print '%s:    %g' % (name, value)
    elif printval.mode != 'F' and value > 1e6:
        print '%s:    %0.5e' % (name, value)
    else:
        print '%s:    %f' % (name, value)

printval.mode = 'G'

def unique(list):
    set = {}
    map(set.__setitem__, list, [])
    return set.keys()

def graphdata68(runs, options, tag, label, value):
    import info
    configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
    benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
    dmas = [ 'x' ]
    caches = [ '2', '4' ]

    names = []

    bench_system = {
        'm' : 'client',
        's' : 'client',
        'snt' : 'client',
        'nb1' : 'server',
        'nb2' : 'server',
        'nt1' : 'server',
        'nt2' : 'server',
        'w1' : 'server',
        'w2' : 'server',
        'w3' : 'server',
        'w4' : 'server',
        'w1s' : 'server',
        'w2s' : 'server',
        'w3s' : 'server',
        'ns' : 'natbox',
        'nm' : 'natbox',
        'nw1' : 'natbox',
        'nw2' : 'natbox',
        'nw3' : 'natbox'
        }

    for bench in benchmarks:
        if bench_system[bench] != options.system:
            continue

        for dma in dmas:
            for cache in caches:
                    names.append([bench, dma, cache])

    for bench,dma,cache in names:
        base = '%s.%s.%s' % (bench, dma, cache)
        fname = 'data/%s.%s.68.dat' % (tag, base)
        f = open(fname, 'w')
        print >>f, '#set TITLE = '
        print >>f, '#set ylbl = %s' % label
        #print >>f, '#set sublabels = %s' % ' '.join(configs)
        print >>f, '#set sublabels = ste hte htd ocm occ ocs'

        for speed,freq in zip(['s', 'm', 'f', 'q'],['4GHz', '6GHz','8GHz', '10GHz']):
            print >>f, '"%s"' % freq,
            for conf in configs:
                name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed)
                run = info.source.allRunNames[name]
                info.display_run = run.run;
                val = float(value)
                if val == 1e300*1e300:
                    print >>f, 0.0,
                else:
                    print >>f, "%f" % val,
            print >>f
        f.close()

def graphdata(runs, options, tag, label, value):
    if options.graph68:
        graphdata68(runs, options, tag, label, value)
        return

    import info
    configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
    #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'nt2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'nw2', 'nw3' ]
    #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'w1', 'w2', 'w3', 'ns', 'nm', 'w1s' ]
    benchmarks = [ 'm', 's', 'nb1', 'nb2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'snt' ]
    #dmas = [ 'x', 'd', 'b' ]
    dmas = [ 'x' ]
    caches = [ '2', '4' ]

    names = []

    bench_system = {
        'm' : 'client',
        's' : 'client',
        'snt' : 'client',
        'nb1' : 'server',
        'nb2' : 'server',
        'nt1' : 'server',
        'nt2' : 'server',
        'w1' : 'server',
        'w2' : 'server',
        'w3' : 'server',
        'w4' : 'server',
        'w1s' : 'server',
        'w2s' : 'server',
        'w3s' : 'server',
        'ns' : 'natbox',
        'nm' : 'natbox',
        'nw1' : 'natbox',
        'nw2' : 'natbox',
        'nw3' : 'natbox'
        }

    for bench in benchmarks:
        if bench_system[bench] != options.system:
            continue

        for dma in dmas:
            for cache in caches:
                    names.append([bench, dma, cache])

    for bench,dma,cache in names:
        base = '%s.%s.%s' % (bench, dma, cache)
        fname = 'data/%s.%s.dat' % (tag, base)
        f = open(fname, 'w')
        print >>f, '#set TITLE = '
        print >>f, '#set ylbl = %s' % label
        #print >>f, '#set sublabels = %s' % ' '.join(configs)
        print >>f, '#set sublabels = ste hte htd ocm occ ocs'

        for speed,freq in zip(['s', 'q'],['4GHz','10GHz']):
            print >>f, '"%s"' % freq,
            for conf in configs:
                name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed)
                run = info.source.allRunNames[name]
                info.display_run = run.run;
                val = float(value)
                if val == 1e300*1e300:
                    print >>f, 0.0,
                else:
                    print >>f, "%f" % val,
            print >>f
        f.close()

def printdata(runs, value, invert = False):
    import info
    for run in runs:
        info.display_run = run.run;
        val = float(value)
        printval(run.name, val)

class CommandException(Exception):
    pass

def commands(options, command, args):
    if command == 'database':
        if len(args) == 0: raise CommandException

        import dbinit
        mydb = dbinit.MyDB(options)

        if args[0] == 'drop':
            if len(args) > 2: raise CommandException
            mydb.admin()
            mydb.drop()
            if len(args) == 2 and args[1] == 'init':
                mydb.create()
                mydb.connect()
                mydb.populate()
            mydb.close()
            return

        if args[0] == 'init':
            if len(args) > 1: raise CommandException
            mydb.admin()
            mydb.create()
            mydb.connect()
            mydb.populate()
            mydb.close()
            return

        if args[0] == 'clean':
            if len(args) > 1: raise CommandException
            mydb.connect()
            mydb.clean()
            return

        raise CommandException

    import db, info
    info.source = db.Database()
    info.source.host = options.host
    info.source.db = options.db
    info.source.passwd = options.passwd
    info.source.user = options.user
    info.source.connect()
    info.source.update_dict(globals())

    if type(options.get) is str:
        info.source.get = options.get

    if options.runs is None:
        runs = info.source.allRuns
    else:
        rx = re.compile(options.runs)
        runs = []
        for run in info.source.allRuns:
            if rx.match(run.name):
                runs.append(run)

    info.display_run = runs[0].run

    if command == 'runs':
        user = None
        opts, args = getopts(args, '-u')
        if len(args):
            raise CommandException
        for o,a in opts:
            if o == '-u':
                user = a
        info.source.listRuns(user)
        return

    if command == 'stability':
        if len(args) < 2:
            raise CommandException

        try:
            merge = int(args[0])
        except ValueError:
            usage()
        stats = info.source.getStat(args[1])
        info.source.get = "sum"


        #loop through all the stats selected
        for stat in stats:

            print "%s:" % stat.name
            print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
                  ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV")
            print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
                  ("--------------------", "------------",
                   "------------", "----", "-----", "-----", "-----", "----------")
            #loop through all the selected runs
            for run in runs:
                info.display_run = run.run;
                runTicks = info.source.retTicks([ run ])
                #throw away the first one, it's 0
                runTicks.pop(0)
                info.globalTicks = runTicks
                avg = 0
                stdev = 0
                numoutsideavg  = 0
                numoutside1std = 0
                numoutside2std = 0
                pairRunTicks = []
                if float(stat) == 1e300*1e300:
                    continue
                for t in range(0, len(runTicks)-(merge-1), merge):
                    tempPair = []
                    for p in range(0,merge):
                        tempPair.append(runTicks[t+p])
                    pairRunTicks.append(tempPair)
                #loop through all the various ticks for each run
                for tick in pairRunTicks:
                    info.globalTicks = tick
                    avg += float(stat)
                avg /= len(pairRunTicks)
                for tick in pairRunTicks:
                    info.globalTicks = tick
                    val = float(stat)
                    stdev += pow((val-avg),2)
                stdev = math.sqrt(stdev / len(pairRunTicks))
                for tick in pairRunTicks:
                    info.globalTicks = tick
                    val = float(stat)
                    if (val < (avg * .9)) or (val > (avg * 1.1)):
                        numoutsideavg += 1
                    if (val < (avg - stdev)) or (val > (avg + stdev)):
                        numoutside1std += 1
                    if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))):
                        numoutside2std += 1
                if avg > 1000:
                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
                          (run.name, "%.1f" % avg, "%.1f" % stdev,
                           "%d" % numoutsideavg, "%d" % numoutside1std,
                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
                           "%.3f" % (stdev/avg*100))
                elif avg > 100:
                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
                          (run.name, "%.1f" % avg, "%.1f" % stdev,
                           "%d" % numoutsideavg, "%d" % numoutside1std,
                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
                           "%.5f" % (stdev/avg*100))
                else:
                    print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
                          (run.name, "%.5f" % avg, "%.5f" % stdev,
                           "%d" % numoutsideavg, "%d" % numoutside1std,
                           "%d" % numoutside2std, "%d" % len(pairRunTicks),
                           "%.7f" % (stdev/avg*100))
        return

    if command == 'stats':
        if len(args) == 0:
            info.source.listStats()
        elif len(args) == 1:
            info.source.listStats(args[0])
        else:
            raise CommandException

        return

    if command == 'stat':
        if len(args) != 1:
            raise CommandException

        stats = info.source.getStat(args[0])
        for stat in stats:
            if options.graph:
                graphdata(runs, options, stat.name, stat.name, stat)
            else:
                if options.ticks:
                   print 'only displaying sample %s' % options.ticks
                   info.globalTicks = [ int(x) for x in options.ticks.split() ]

                if options.binned:
                    print 'kernel ticks'
                    stat.bins = 'kernel'
                    printdata(runs, stat)

                    print 'idle ticks'
                    stat.bins = 'idle'
                    printdata(runs, stat)

                    print 'user ticks'
                    stat.bins = 'user'
                    printdata(runs, stat)

                    print 'interrupt ticks'
                    stat.bins = 'interrupt'
                    printdata(runs, stat)

                    print 'total ticks'

                stat.bins = None
                print stat.name
                printdata(runs, stat)
        return

    if command == 'formula':
        if len(args) != 1:
            raise CommandException

        stats = eval(args[0])
        for stat in stats:
            if options.graph:
                graphdata(runs, options, stat.name, stat.name, stat)
            else:
                if options.binned:
                    print 'kernel ticks'
                    stat.bins = 'kernel'
                    printdata(runs, stat)

                    print 'idle ticks'
                    stat.bins = 'idle'
                    printdata(runs, stat)

                    print 'user ticks'
                    stat.bins = 'user'
                    printdata(runs, stat)

                    print 'interrupt ticks'
                    stat.bins = 'interrupt'
                    printdata(runs, stat)

                    print 'total ticks'

                stat.bins = None
                print args[0]
                printdata(runs, stat)
        return

    if command == 'bins':
        if len(args) == 0:
            info.source.listBins()
        elif len(args) == 1:
            info.source.listBins(args[0])
        else:
            raise CommandException

        return

    if command == 'formulas':
        if len(args) == 0:
            info.source.listFormulas()
        elif len(args) == 1:
            info.source.listFormulas(args[0])
        else:
            raise CommandException

        return

    if command == 'samples':
        if len(args):
            raise CommandException

        info.source.listTicks(runs)
        return

    if len(args):
        raise CommandException

    system = info.source.__dict__[options.system]

    if command == 'usertime':
        import copy
        kernel = copy.copy(system.full0.numCycles)
        kernel.bins = 'kernel'

        user = copy.copy(system.full0.numCycles)
        user.bins = 'user'

        if options.graph:
            graphdata(runs, options, 'usertime', 'User Fraction',
                      user / system.full0.numCycles)
        else:
            printdata(runs, user / system.full0.numCycles)
        return

    if command == 'ticks':
        if options.binned:
            print 'kernel ticks'
            system.full0.numCycles.bins = 'kernel'
            printdata(runs, system.full0.numCycles)

            print 'idle ticks'
            system.full0.numCycles.bins = 'idle'
            printdata(runs, system.full0.numCycles)

            print 'user ticks'
            system.full0.numCycles.bins = 'user'
            printdata(runs, system.full0.numCycles)

            print 'total ticks'

        system.full0.numCycles.bins = None
        printdata(runs, system.full0.numCycles)
        return

    if command == 'packets':
        packets = system.tsunami.etherdev0.rxPackets
        if options.graph:
            graphdata(runs, options, 'packets', 'Packets', packets)
        else:
            printdata(runs, packets)
        return

    if command == 'ppt' or command == 'tpp':
        ppt = system.tsunami.etherdev0.rxPackets / sim_ticks
        printdata(runs, ppt, command == 'tpp')
        return

    if command == 'pps':
        pps = system.tsunami.etherdev0.rxPackets / sim_seconds
        if options.graph:
            graphdata(runs, options, 'pps', 'Packets/s', pps)
        else:
            printdata(runs, pps)
        return

    if command == 'bpt' or command == 'tpb':
        bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
        bpt = bytes / sim_ticks * 8
        if options.graph:
            graphdata(runs, options, 'bpt', 'bps / Hz', bpt)
        else:
            printdata(runs, bpt, command == 'tpb')
        return

    if command == 'bptb' or command == 'tpbb':
        bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes

        print 'kernel stats'
        bytes.bins = 'kernel'
        printdata(runs, bytes / ticks)

        print 'idle stats'
        bytes.bins = 'idle'
        printdata(runs, bytes / ticks)

        print 'user stats'
        bytes.bins = 'user'
        printdata(runs, bytes / ticks)

        return

    if command == 'bytes':
        stat = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes

        if options.binned:
            print '%s kernel stats' % stat.name
            stat.bins = 'kernel'
            printdata(runs, stat)

            print '%s idle stats' % stat.name
            stat.bins = 'idle'
            printdata(runs, stat)

            print '%s user stats' % stat.name
            stat.bins = 'user'
            printdata(runs, stat)

            print '%s total stats' % stat.name
            stat.bins = None

        printdata(runs, stat)
        return

    if command == 'rxbps':
        gbps = system.tsunami.etherdev0.rxBandwidth / 1e9
        if options.graph:
            graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)',  gbps)
        else:
            printdata(runs, gbps)
        return

    if command == 'txbps':
        gbps = system.tsunami.etherdev0.txBandwidth / 1e9
        if options.graph:
            graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)',  gbps)
        else:
            printdata(runs, gbps)
        return

    if command == 'bps':
        rxbps = system.tsunami.etherdev0.rxBandwidth
        txbps = system.tsunami.etherdev0.txBandwidth
        gbps = (rxbps + txbps) / 1e9
        if options.graph:
            graphdata(runs, options, 'bps', 'Bandwidth (Gbps)',  gbps)
        else:
            printdata(runs, gbps)
        return

    if command == 'misses':
        stat = system.l2.overall_mshr_misses
        if options.binned:
            print '%s kernel stats' % stat.name
            stat.bins = 'kernel'
            printdata(runs, stat)

            print '%s idle stats' % stat.name
            stat.bins = 'idle'
            printdata(runs, stat)

            print '%s user stats' % stat.name
            stat.bins = 'user'
            printdata(runs, stat)

            print '%s total stats' % stat.name

        stat.bins = None
        if options.graph:
            graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat)
        else:
            printdata(runs, stat)
        return

    if command == 'mpkb':
        misses = system.l2.overall_mshr_misses
        rxbytes = system.tsunami.etherdev0.rxBytes
        txbytes = system.tsunami.etherdev0.txBytes

        if options.binned:
            print 'mpkb kernel stats'
            misses.bins = 'kernel'
            mpkb = misses / ((rxbytes + txbytes) / 1024)
            printdata(runs, mpkb)

            print 'mpkb idle stats'
            misses.bins = 'idle'
            mpkb = misses / ((rxbytes + txbytes) / 1024)
            printdata(runs, mpkb)

            print 'mpkb user stats'
            misses.bins = 'user'
            mpkb = misses / ((rxbytes + txbytes) / 1024)
            printdata(runs, mpkb)

            print 'mpkb total stats'

        mpkb = misses / ((rxbytes + txbytes) / 1024)
        misses.bins = None
        if options.graph:
            graphdata(runs, options, 'mpkb', 'Misses / KB',  mpkb)
        else:
            printdata(runs, mpkb)
        return

    if command == 'ipkb':
        interrupts = system.full0.kern.faults[4]
        rxbytes = system.tsunami.etherdev0.rxBytes
        txbytes = system.tsunami.etherdev0.txBytes

        if options.binned:
            print 'ipkb kernel stats'
            interrupts.bins = 'kernel'
            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
            printdata(runs, ipkb)

            print 'ipkb idle stats'
            interrupts.bins = 'idle'
            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
            printdata(runs, ipkb)

            print 'ipkb user stats'
            interrupts.bins = 'user'
            ipkb = interrupts / ((rxbytes + txbytes) / 1024)
            printdata(runs, ipkb)

            print 'ipkb total stats'

        ipkb = interrupts / ((rxbytes + txbytes) / 1024)
        interrupts.bins = None
        if options.graph:
            graphdata(runs, options, 'ipkb', 'Interrupts / KB',  ipkb)
        else:
            printdata(runs, ipkb)
        return

    if command == 'execute':
        printdata(runs, system.full0.ISSUE__count)
        return

    if command == 'commit':
        printdata(runs, system.full0.COM__count)
        return

    if command == 'fetch':
        printdata(runs, system.full0.FETCH__count)
        return

    if command == 'bpp':
        ed = system.tsunami.etherdev0
        bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets)
        if options.graph:
            graphdata(runs, options, 'bpp', 'Bytes / Packet',  bpp)
        else:
            printdata(runs, bpp)
        return

    if command == 'rxbpp':
        bpp = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.rxPackets
        if options.graph:
            graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet',  bpp)
        else:
            printdata(runs, bpp)
        return

    if command == 'txbpp':
        bpp = system.tsunami.etherdev0.txBytes / system.tsunami.etherdev0.txPackets
        if options.graph:
            graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet',  bpp)
        else:
            printdata(runs, bpp)
        return

    if command == 'rtp':
        rtp = system.tsunami.etherdev0.rxPackets / system.tsunami.etherdev0.txPackets
        if options.graph:
            graphdata(runs, options, 'rtp', 'rxPackets / txPackets',  rtp)
        else:
            printdata(runs, rtp)
        return

    if command == 'rtb':
        rtb = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.txBytes
        if options.graph:
            graphdata(runs, options, 'rtb', 'rxBytes / txBytes',  rtb)
        else:
            printdata(runs, rtb)
        return

    raise CommandException


class Options: pass

if __name__ == '__main__':
    import getpass

    options = Options()
    options.host = 'zizzer.pool'
    options.db = None
    options.passwd = ''
    options.user = getpass.getuser()
    options.runs = None
    options.system = 'client'
    options.get = None
    options.binned = False
    options.graph = False
    options.graph68 = False
    options.ticks = False

    opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:')
    for o,a in opts:
        if o == '-6':
            options.graph68 = True
        if o == '-B':
            options.binned = True
        if o == '-E':
            printval.mode = 'E'
        if o == '-F':
            printval.mode = 'F'
        if o == '-G':
            options.graph = True;
        if o == '-d':
            options.db = a
        if o == '-g':
            options.get = a
        if o == '-h':
            options.host = a
        if o == '-p':
            options.passwd = getpass.getpass()
        if o == '-r':
            options.runs = a
        if o == '-u':
            options.user = a
        if o == '-s':
            options.system = a
        if o == '-T':
            options.ticks = a

    if len(args) == 0:
        usage()

    command = args[0]
    args = args[1:]

    try:
        commands(options, command, args)
    except CommandException:
        usage()