stats.py (1758:74acd5b23964) stats.py (1772:a3a83e812a5e)
1#!/usr/bin/env python
2
3# Copyright (c) 2003-2004 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer;
10# redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution;
13# neither the name of the copyright holders nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
1#!/usr/bin/env python
2
3# Copyright (c) 2003-2004 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer;
10# redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution;
13# neither the name of the copyright holders nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29#Permission is granted to use, copy, create derivative works and
30#redistribute this software and such derivative works for any purpose,
31#so long as the copyright notice above, this grant of permission, and
32#the disclaimer below appear in all copies made; and so long as the
33#name of The University of Michigan is not used in any advertising or
34#publicity pertaining to the use or distribution of this software
35#without specific, written prior authorization.
36#
37#THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE
38#UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT
39#WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR
40#IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
41#MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF
42#THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES,
43#INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
44#DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION
45#WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER
46#ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47
48from __future__ import division
49import re, sys, math
50
51
52def usage():
53 print '''\
54Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
55 [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>]
56 <command> [command args]
57
58 commands extra parameters description
59 ----------- ------------------ ---------------------------------------
60 bins [regex] List bins (only matching regex)
61 formula <formula> Evaluated formula specified
62 formulas [regex] List formulas (only matching regex)
63 runs none List all runs in database
64 samples none List samples present in database
65 stability <pairnum> <stats> Calculated statistical info about stats
66 stat <regex> Show stat data (only matching regex)
67 stats [regex] List all stats (only matching regex)
68
69 database <command> Where command is drop, init, or clean
70
71''' % sys.argv[0]
72 sys.exit(1)
73
74def getopts(list, flags):
75 import getopt
76 try:
77 opts, args = getopt.getopt(list, flags)
78 except getopt.GetoptError:
79 usage()
80
81 return opts, args
82
83def printval(name, value, invert = False):
84 if invert and value != 0.0:
85 value = 1 / value
86
87 if value == (1e300*1e300):
88 return
89
90 if printval.mode == 'G':
91 print '%s: %g' % (name, value)
92 elif printval.mode != 'F' and value > 1e6:
93 print '%s: %0.5e' % (name, value)
94 else:
95 print '%s: %f' % (name, value)
96
97printval.mode = 'G'
98
99def unique(list):
100 set = {}
101 map(set.__setitem__, list, [])
102 return set.keys()
103
104#benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
105
106def graphdata(runs, options, tag, label, value):
107 import info
108
109 bench_system = {
110 'm' : 'client',
111 's' : 'client',
112 'snt' : 'client',
113 'nb1' : 'server',
114 'nb2' : 'server',
115 'nt1' : 'server',
116 'nt2' : 'server',
117 'w1' : 'server',
118 'w2' : 'server',
119 'w3' : 'server',
120 'w4' : 'server',
121 'w1s' : 'server',
122 'w2s' : 'server',
123 'w3s' : 'server',
124 'ns' : 'natbox',
125 'nm' : 'natbox',
126 'nw1' : 'natbox',
127 'nw2' : 'natbox',
128 'nw3' : 'natbox'
129 }
130
131 system_configs = {
132 's1' : 'Uni 4GHz',
133 'm1' : 'Uni 6GHz',
134 'f1' : 'Uni 8GHz',
135 'q1' : 'Uni 10GHz',
136 's2' : 'Dual 4GHz',
137 'm2' : 'Dual 6GHz',
138 's4' : 'Quad 4GHz',
139 'm4' : 'Quad 6GHz' }
140
141 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
142 benchmarks = [ 'm', 'snt', 'w2', 'nm', 'nw2' ]
143 caches = [ '0', '2', '4' ]
144
145 names = []
146 for bench in benchmarks:
147 if bench_system[bench] != options.system:
148 continue
149
150 for cache in caches:
151 names.append([bench, cache])
152
153 for bench,cache in names:
154 base = '%s.%s' % (bench, cache)
155 fname = 'data/uni.%s.%s.dat' % (tag, base)
156 f = open(fname, 'w')
157 print >>f, '#set TITLE = '
158 print >>f, '#set ylbl = %s' % label
159 #print >>f, '#set sublabels = %s' % ' '.join(configs)
160 print >>f, '#set sublabels = ste hte htd ocm occ ocs'
161
162 for speed in ('s1', 'm1', 'f1', 'q1'):
163 label = system_configs[speed]
164 print >>f, '"%s"' % label,
165 for conf in configs:
166 name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
167 run = info.source.allRunNames[name]
168 info.display_run = run.run;
169 val = float(value)
170 if val == 1e300*1e300:
171 print >>f, 0.0,
172 else:
173 print >>f, "%f" % val,
174 print >>f
175 f.close()
176
177 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
178 benchmarks = [ 'w2']
179 caches = [ '0', '2', '4' ]
180
181 names = []
182 for bench in benchmarks:
183 if bench_system[bench] != options.system:
184 continue
185
186 for cache in caches:
187 names.append([bench, cache])
188
189 for bench,cache in names:
190 base = '%s.%s' % (bench, cache)
191 fname = 'data/mp.%s.%s.dat' % (tag, base)
192 f = open(fname, 'w')
193 print >>f, '#set TITLE = '
194 print >>f, '#set ylbl = %s' % label
195 #print >>f, '#set sublabels = %s' % ' '.join(configs)
196 print >>f, '#set sublabels = ste hte htd ocm occ ocs'
197
198 for speed in ('s2', 'm2', 's4', 'm4'):
199 label = system_configs[speed]
200 print >>f, '"%s"' % label,
201 for conf in configs:
202 name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
203 run = info.source.allRunNames[name]
204 info.display_run = run.run;
205 val = float(value)
206 if val == 1e300*1e300:
207 print >>f, 0.0,
208 else:
209 print >>f, "%f" % val,
210 print >>f
211 f.close()
212
213def printdata(runs, value, invert = False):
214 import info
215 for run in runs:
216 info.display_run = run.run;
217 val = float(value)
218 printval(run.name, val)
219
220class CommandException(Exception):
221 pass
222
223def commands(options, command, args):
224 if command == 'database':
225 if len(args) == 0: raise CommandException
226
227 import dbinit
228 mydb = dbinit.MyDB(options)
229
230 if args[0] == 'drop':
231 if len(args) > 2: raise CommandException
232 mydb.admin()
233 mydb.drop()
234 if len(args) == 2 and args[1] == 'init':
235 mydb.create()
236 mydb.connect()
237 mydb.populate()
238 mydb.close()
239 return
240
241 if args[0] == 'init':
242 if len(args) > 1: raise CommandException
243 mydb.admin()
244 mydb.create()
245 mydb.connect()
246 mydb.populate()
247 mydb.close()
248 return
249
250 if args[0] == 'clean':
251 if len(args) > 1: raise CommandException
252 mydb.connect()
253 mydb.clean()
254 return
255
256 raise CommandException
257
258 import db, info
259 info.source = db.Database()
260 info.source.host = options.host
261 info.source.db = options.db
262 info.source.passwd = options.passwd
263 info.source.user = options.user
264 info.source.connect()
265 info.source.update_dict(globals())
266
267 if type(options.get) is str:
268 info.source.get = options.get
269
270 if options.runs is None:
271 runs = info.source.allRuns
272 else:
273 rx = re.compile(options.runs)
274 runs = []
275 for run in info.source.allRuns:
276 if rx.match(run.name):
277 runs.append(run)
278
279 info.display_run = runs[0].run
280
281 if command == 'runs':
282 user = None
283 opts, args = getopts(args, '-u')
284 if len(args):
285 raise CommandException
286 for o,a in opts:
287 if o == '-u':
288 user = a
289 info.source.listRuns(user)
290 return
291
292 if command == 'stability':
293 if len(args) < 2:
294 raise CommandException
295
296 try:
297 merge = int(args[0])
298 except ValueError:
299 usage()
300 stats = info.source.getStat(args[1])
301 info.source.get = "sum"
302
303
304 #loop through all the stats selected
305 for stat in stats:
306
307 print "%s:" % stat.name
308 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
309 ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV")
310 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
311 ("--------------------", "------------",
312 "------------", "----", "-----", "-----", "-----", "----------")
313 #loop through all the selected runs
314 for run in runs:
315 info.display_run = run.run;
316 runTicks = info.source.retTicks([ run ])
317 #throw away the first one, it's 0
318 runTicks.pop(0)
319 info.globalTicks = runTicks
320 avg = 0
321 stdev = 0
322 numoutsideavg = 0
323 numoutside1std = 0
324 numoutside2std = 0
325 pairRunTicks = []
326 if float(stat) == 1e300*1e300:
327 continue
328 for t in range(0, len(runTicks)-(merge-1), merge):
329 tempPair = []
330 for p in range(0,merge):
331 tempPair.append(runTicks[t+p])
332 pairRunTicks.append(tempPair)
333 #loop through all the various ticks for each run
334 for tick in pairRunTicks:
335 info.globalTicks = tick
336 avg += float(stat)
337 avg /= len(pairRunTicks)
338 for tick in pairRunTicks:
339 info.globalTicks = tick
340 val = float(stat)
341 stdev += pow((val-avg),2)
342 stdev = math.sqrt(stdev / len(pairRunTicks))
343 for tick in pairRunTicks:
344 info.globalTicks = tick
345 val = float(stat)
346 if (val < (avg * .9)) or (val > (avg * 1.1)):
347 numoutsideavg += 1
348 if (val < (avg - stdev)) or (val > (avg + stdev)):
349 numoutside1std += 1
350 if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))):
351 numoutside2std += 1
352 if avg > 1000:
353 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
354 (run.name, "%.1f" % avg, "%.1f" % stdev,
355 "%d" % numoutsideavg, "%d" % numoutside1std,
356 "%d" % numoutside2std, "%d" % len(pairRunTicks),
357 "%.3f" % (stdev/avg*100))
358 elif avg > 100:
359 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
360 (run.name, "%.1f" % avg, "%.1f" % stdev,
361 "%d" % numoutsideavg, "%d" % numoutside1std,
362 "%d" % numoutside2std, "%d" % len(pairRunTicks),
363 "%.5f" % (stdev/avg*100))
364 else:
365 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
366 (run.name, "%.5f" % avg, "%.5f" % stdev,
367 "%d" % numoutsideavg, "%d" % numoutside1std,
368 "%d" % numoutside2std, "%d" % len(pairRunTicks),
369 "%.7f" % (stdev/avg*100))
370 return
371
372 if command == 'stats':
373 if len(args) == 0:
374 info.source.listStats()
375 elif len(args) == 1:
376 info.source.listStats(args[0])
377 else:
378 raise CommandException
379
380 return
381
382 if command == 'stat':
383 if len(args) != 1:
384 raise CommandException
385
386 stats = info.source.getStat(args[0])
387 for stat in stats:
388 if options.graph:
389 graphdata(runs, options, stat.name, stat.name, stat)
390 else:
391 if options.ticks:
392 print 'only displaying sample %s' % options.ticks
393 info.globalTicks = [ int(x) for x in options.ticks.split() ]
394
395 if options.binned:
396 print 'kernel ticks'
397 stat.bins = 'kernel'
398 printdata(runs, stat)
399
400 print 'idle ticks'
401 stat.bins = 'idle'
402 printdata(runs, stat)
403
404 print 'user ticks'
405 stat.bins = 'user'
406 printdata(runs, stat)
407
408 print 'interrupt ticks'
409 stat.bins = 'interrupt'
410 printdata(runs, stat)
411
412 print 'total ticks'
413
414 stat.bins = None
415 print stat.name
416 printdata(runs, stat)
417 return
418
419 if command == 'formula':
420 if len(args) != 1:
421 raise CommandException
422
423 stats = eval(args[0])
424 for stat in stats:
425 if options.graph:
426 graphdata(runs, options, stat.name, stat.name, stat)
427 else:
428 if options.binned:
429 print 'kernel ticks'
430 stat.bins = 'kernel'
431 printdata(runs, stat)
432
433 print 'idle ticks'
434 stat.bins = 'idle'
435 printdata(runs, stat)
436
437 print 'user ticks'
438 stat.bins = 'user'
439 printdata(runs, stat)
440
441 print 'interrupt ticks'
442 stat.bins = 'interrupt'
443 printdata(runs, stat)
444
445 print 'total ticks'
446
447 stat.bins = None
448 print args[0]
449 printdata(runs, stat)
450 return
451
452 if command == 'bins':
453 if len(args) == 0:
454 info.source.listBins()
455 elif len(args) == 1:
456 info.source.listBins(args[0])
457 else:
458 raise CommandException
459
460 return
461
462 if command == 'formulas':
463 if len(args) == 0:
464 info.source.listFormulas()
465 elif len(args) == 1:
466 info.source.listFormulas(args[0])
467 else:
468 raise CommandException
469
470 return
471
472 if command == 'samples':
473 if len(args):
474 raise CommandException
475
476 info.source.listTicks(runs)
477 return
478
479 if len(args):
480 raise CommandException
481
482 system = info.source.__dict__[options.system]
483
484 if command == 'usertime':
485 import copy
486 kernel = copy.copy(system.full0.numCycles)
487 kernel.bins = 'kernel'
488
489 user = copy.copy(system.full0.numCycles)
490 user.bins = 'user'
491
492 if options.graph:
493 graphdata(runs, options, 'usertime', 'User Fraction',
494 user / system.full0.numCycles)
495 else:
496 printdata(runs, user / system.full0.numCycles)
497 return
498
499 if command == 'ticks':
500 if options.binned:
501 print 'kernel ticks'
502 system.full0.numCycles.bins = 'kernel'
503 printdata(runs, system.full0.numCycles)
504
505 print 'idle ticks'
506 system.full0.numCycles.bins = 'idle'
507 printdata(runs, system.full0.numCycles)
508
509 print 'user ticks'
510 system.full0.numCycles.bins = 'user'
511 printdata(runs, system.full0.numCycles)
512
513 print 'total ticks'
514
515 system.full0.numCycles.bins = None
516 printdata(runs, system.full0.numCycles)
517 return
518
519 if command == 'packets':
520 packets = system.tsunami.etherdev0.rxPackets
521 if options.graph:
522 graphdata(runs, options, 'packets', 'Packets', packets)
523 else:
524 printdata(runs, packets)
525 return
526
527 if command == 'ppt' or command == 'tpp':
528 ppt = system.tsunami.etherdev0.rxPackets / sim_ticks
529 printdata(runs, ppt, command == 'tpp')
530 return
531
532 if command == 'pps':
533 pps = system.tsunami.etherdev0.rxPackets / sim_seconds
534 if options.graph:
535 graphdata(runs, options, 'pps', 'Packets/s', pps)
536 else:
537 printdata(runs, pps)
538 return
539
540 if command == 'bpt' or command == 'tpb':
541 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
542 bpt = bytes / sim_ticks * 8
543 if options.graph:
544 graphdata(runs, options, 'bpt', 'bps / Hz', bpt)
545 else:
546 printdata(runs, bpt, command == 'tpb')
547 return
548
549 if command == 'bptb' or command == 'tpbb':
550 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
551
552 print 'kernel stats'
553 bytes.bins = 'kernel'
554 printdata(runs, bytes / ticks)
555
556 print 'idle stats'
557 bytes.bins = 'idle'
558 printdata(runs, bytes / ticks)
559
560 print 'user stats'
561 bytes.bins = 'user'
562 printdata(runs, bytes / ticks)
563
564 return
565
566 if command == 'bytes':
567 stat = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
568
569 if options.binned:
570 print '%s kernel stats' % stat.name
571 stat.bins = 'kernel'
572 printdata(runs, stat)
573
574 print '%s idle stats' % stat.name
575 stat.bins = 'idle'
576 printdata(runs, stat)
577
578 print '%s user stats' % stat.name
579 stat.bins = 'user'
580 printdata(runs, stat)
581
582 print '%s total stats' % stat.name
583 stat.bins = None
584
585 printdata(runs, stat)
586 return
587
588 if command == 'rxbps':
589 gbps = system.tsunami.etherdev0.rxBandwidth / 1e9
590 if options.graph:
591 graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps)
592 else:
593 printdata(runs, gbps)
594 return
595
596 if command == 'txbps':
597 gbps = system.tsunami.etherdev0.txBandwidth / 1e9
598 if options.graph:
599 graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps)
600 else:
601 printdata(runs, gbps)
602 return
603
604 if command == 'bps':
605 rxbps = system.tsunami.etherdev0.rxBandwidth
606 txbps = system.tsunami.etherdev0.txBandwidth
607 gbps = (rxbps + txbps) / 1e9
608 if options.graph:
609 graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps)
610 else:
611 printdata(runs, gbps)
612 return
613
614 if command == 'misses':
615 stat = system.l2.overall_mshr_misses
616 if options.binned:
617 print '%s kernel stats' % stat.name
618 stat.bins = 'kernel'
619 printdata(runs, stat)
620
621 print '%s idle stats' % stat.name
622 stat.bins = 'idle'
623 printdata(runs, stat)
624
625 print '%s user stats' % stat.name
626 stat.bins = 'user'
627 printdata(runs, stat)
628
629 print '%s total stats' % stat.name
630
631 stat.bins = None
632 if options.graph:
633 graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat)
634 else:
635 printdata(runs, stat)
636 return
637
638 if command == 'mpkb':
639 misses = system.l2.overall_mshr_misses
640 rxbytes = system.tsunami.etherdev0.rxBytes
641 txbytes = system.tsunami.etherdev0.txBytes
642
643 if options.binned:
644 print 'mpkb kernel stats'
645 misses.bins = 'kernel'
646 mpkb = misses / ((rxbytes + txbytes) / 1024)
647 printdata(runs, mpkb)
648
649 print 'mpkb idle stats'
650 misses.bins = 'idle'
651 mpkb = misses / ((rxbytes + txbytes) / 1024)
652 printdata(runs, mpkb)
653
654 print 'mpkb user stats'
655 misses.bins = 'user'
656 mpkb = misses / ((rxbytes + txbytes) / 1024)
657 printdata(runs, mpkb)
658
659 print 'mpkb total stats'
660
661 mpkb = misses / ((rxbytes + txbytes) / 1024)
662 misses.bins = None
663 if options.graph:
664 graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb)
665 else:
666 printdata(runs, mpkb)
667 return
668
669 if command == 'ipkb':
670 interrupts = system.full0.kern.faults[4]
671 rxbytes = system.tsunami.etherdev0.rxBytes
672 txbytes = system.tsunami.etherdev0.txBytes
673
674 if options.binned:
675 print 'ipkb kernel stats'
676 interrupts.bins = 'kernel'
677 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
678 printdata(runs, ipkb)
679
680 print 'ipkb idle stats'
681 interrupts.bins = 'idle'
682 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
683 printdata(runs, ipkb)
684
685 print 'ipkb user stats'
686 interrupts.bins = 'user'
687 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
688 printdata(runs, ipkb)
689
690 print 'ipkb total stats'
691
692 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
693 interrupts.bins = None
694 if options.graph:
695 graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb)
696 else:
697 printdata(runs, ipkb)
698 return
699
700 if command == 'execute':
701 printdata(runs, system.full0.ISSUE__count)
702 return
703
704 if command == 'commit':
705 printdata(runs, system.full0.COM__count)
706 return
707
708 if command == 'fetch':
709 printdata(runs, system.full0.FETCH__count)
710 return
711
712 if command == 'bpp':
713 ed = system.tsunami.etherdev0
714 bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets)
715 if options.graph:
716 graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp)
717 else:
718 printdata(runs, bpp)
719 return
720
721 if command == 'rxbpp':
722 bpp = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.rxPackets
723 if options.graph:
724 graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp)
725 else:
726 printdata(runs, bpp)
727 return
728
729 if command == 'txbpp':
730 bpp = system.tsunami.etherdev0.txBytes / system.tsunami.etherdev0.txPackets
731 if options.graph:
732 graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp)
733 else:
734 printdata(runs, bpp)
735 return
736
737 if command == 'rtp':
738 rtp = system.tsunami.etherdev0.rxPackets / system.tsunami.etherdev0.txPackets
739 if options.graph:
740 graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp)
741 else:
742 printdata(runs, rtp)
743 return
744
745 if command == 'rtb':
746 rtb = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.txBytes
747 if options.graph:
748 graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb)
749 else:
750 printdata(runs, rtb)
751 return
752
753 raise CommandException
754
755
756class Options: pass
757
758if __name__ == '__main__':
759 import getpass
760
761 options = Options()
762 options.host = 'zizzer.pool'
763 options.db = None
764 options.passwd = ''
765 options.user = getpass.getuser()
766 options.runs = None
767 options.system = 'client'
768 options.get = None
769 options.binned = False
770 options.graph = False
771 options.ticks = False
772
773 opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:')
774 for o,a in opts:
775 if o == '-B':
776 options.binned = True
777 if o == '-E':
778 printval.mode = 'E'
779 if o == '-F':
780 printval.mode = 'F'
781 if o == '-G':
782 options.graph = True;
783 if o == '-d':
784 options.db = a
785 if o == '-g':
786 options.get = a
787 if o == '-h':
788 options.host = a
789 if o == '-p':
790 options.passwd = getpass.getpass()
791 if o == '-r':
792 options.runs = a
793 if o == '-u':
794 options.user = a
795 if o == '-s':
796 options.system = a
797 if o == '-T':
798 options.ticks = a
799
800 if len(args) == 0:
801 usage()
802
803 command = args[0]
804 args = args[1:]
805
806 try:
807 commands(options, command, args)
808 except CommandException:
809 usage()
29from __future__ import division
30import re, sys, math
31
32
33def usage():
34 print '''\
35Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
36 [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>]
37 <command> [command args]
38
39 commands extra parameters description
40 ----------- ------------------ ---------------------------------------
41 bins [regex] List bins (only matching regex)
42 formula <formula> Evaluated formula specified
43 formulas [regex] List formulas (only matching regex)
44 runs none List all runs in database
45 samples none List samples present in database
46 stability <pairnum> <stats> Calculated statistical info about stats
47 stat <regex> Show stat data (only matching regex)
48 stats [regex] List all stats (only matching regex)
49
50 database <command> Where command is drop, init, or clean
51
52''' % sys.argv[0]
53 sys.exit(1)
54
55def getopts(list, flags):
56 import getopt
57 try:
58 opts, args = getopt.getopt(list, flags)
59 except getopt.GetoptError:
60 usage()
61
62 return opts, args
63
64def printval(name, value, invert = False):
65 if invert and value != 0.0:
66 value = 1 / value
67
68 if value == (1e300*1e300):
69 return
70
71 if printval.mode == 'G':
72 print '%s: %g' % (name, value)
73 elif printval.mode != 'F' and value > 1e6:
74 print '%s: %0.5e' % (name, value)
75 else:
76 print '%s: %f' % (name, value)
77
78printval.mode = 'G'
79
80def unique(list):
81 set = {}
82 map(set.__setitem__, list, [])
83 return set.keys()
84
85#benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
86
87def graphdata(runs, options, tag, label, value):
88 import info
89
90 bench_system = {
91 'm' : 'client',
92 's' : 'client',
93 'snt' : 'client',
94 'nb1' : 'server',
95 'nb2' : 'server',
96 'nt1' : 'server',
97 'nt2' : 'server',
98 'w1' : 'server',
99 'w2' : 'server',
100 'w3' : 'server',
101 'w4' : 'server',
102 'w1s' : 'server',
103 'w2s' : 'server',
104 'w3s' : 'server',
105 'ns' : 'natbox',
106 'nm' : 'natbox',
107 'nw1' : 'natbox',
108 'nw2' : 'natbox',
109 'nw3' : 'natbox'
110 }
111
112 system_configs = {
113 's1' : 'Uni 4GHz',
114 'm1' : 'Uni 6GHz',
115 'f1' : 'Uni 8GHz',
116 'q1' : 'Uni 10GHz',
117 's2' : 'Dual 4GHz',
118 'm2' : 'Dual 6GHz',
119 's4' : 'Quad 4GHz',
120 'm4' : 'Quad 6GHz' }
121
122 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
123 benchmarks = [ 'm', 'snt', 'w2', 'nm', 'nw2' ]
124 caches = [ '0', '2', '4' ]
125
126 names = []
127 for bench in benchmarks:
128 if bench_system[bench] != options.system:
129 continue
130
131 for cache in caches:
132 names.append([bench, cache])
133
134 for bench,cache in names:
135 base = '%s.%s' % (bench, cache)
136 fname = 'data/uni.%s.%s.dat' % (tag, base)
137 f = open(fname, 'w')
138 print >>f, '#set TITLE = '
139 print >>f, '#set ylbl = %s' % label
140 #print >>f, '#set sublabels = %s' % ' '.join(configs)
141 print >>f, '#set sublabels = ste hte htd ocm occ ocs'
142
143 for speed in ('s1', 'm1', 'f1', 'q1'):
144 label = system_configs[speed]
145 print >>f, '"%s"' % label,
146 for conf in configs:
147 name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
148 run = info.source.allRunNames[name]
149 info.display_run = run.run;
150 val = float(value)
151 if val == 1e300*1e300:
152 print >>f, 0.0,
153 else:
154 print >>f, "%f" % val,
155 print >>f
156 f.close()
157
158 configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
159 benchmarks = [ 'w2']
160 caches = [ '0', '2', '4' ]
161
162 names = []
163 for bench in benchmarks:
164 if bench_system[bench] != options.system:
165 continue
166
167 for cache in caches:
168 names.append([bench, cache])
169
170 for bench,cache in names:
171 base = '%s.%s' % (bench, cache)
172 fname = 'data/mp.%s.%s.dat' % (tag, base)
173 f = open(fname, 'w')
174 print >>f, '#set TITLE = '
175 print >>f, '#set ylbl = %s' % label
176 #print >>f, '#set sublabels = %s' % ' '.join(configs)
177 print >>f, '#set sublabels = ste hte htd ocm occ ocs'
178
179 for speed in ('s2', 'm2', 's4', 'm4'):
180 label = system_configs[speed]
181 print >>f, '"%s"' % label,
182 for conf in configs:
183 name = '%s.%s.%s.%s' % (conf, bench, cache, speed)
184 run = info.source.allRunNames[name]
185 info.display_run = run.run;
186 val = float(value)
187 if val == 1e300*1e300:
188 print >>f, 0.0,
189 else:
190 print >>f, "%f" % val,
191 print >>f
192 f.close()
193
194def printdata(runs, value, invert = False):
195 import info
196 for run in runs:
197 info.display_run = run.run;
198 val = float(value)
199 printval(run.name, val)
200
201class CommandException(Exception):
202 pass
203
204def commands(options, command, args):
205 if command == 'database':
206 if len(args) == 0: raise CommandException
207
208 import dbinit
209 mydb = dbinit.MyDB(options)
210
211 if args[0] == 'drop':
212 if len(args) > 2: raise CommandException
213 mydb.admin()
214 mydb.drop()
215 if len(args) == 2 and args[1] == 'init':
216 mydb.create()
217 mydb.connect()
218 mydb.populate()
219 mydb.close()
220 return
221
222 if args[0] == 'init':
223 if len(args) > 1: raise CommandException
224 mydb.admin()
225 mydb.create()
226 mydb.connect()
227 mydb.populate()
228 mydb.close()
229 return
230
231 if args[0] == 'clean':
232 if len(args) > 1: raise CommandException
233 mydb.connect()
234 mydb.clean()
235 return
236
237 raise CommandException
238
239 import db, info
240 info.source = db.Database()
241 info.source.host = options.host
242 info.source.db = options.db
243 info.source.passwd = options.passwd
244 info.source.user = options.user
245 info.source.connect()
246 info.source.update_dict(globals())
247
248 if type(options.get) is str:
249 info.source.get = options.get
250
251 if options.runs is None:
252 runs = info.source.allRuns
253 else:
254 rx = re.compile(options.runs)
255 runs = []
256 for run in info.source.allRuns:
257 if rx.match(run.name):
258 runs.append(run)
259
260 info.display_run = runs[0].run
261
262 if command == 'runs':
263 user = None
264 opts, args = getopts(args, '-u')
265 if len(args):
266 raise CommandException
267 for o,a in opts:
268 if o == '-u':
269 user = a
270 info.source.listRuns(user)
271 return
272
273 if command == 'stability':
274 if len(args) < 2:
275 raise CommandException
276
277 try:
278 merge = int(args[0])
279 except ValueError:
280 usage()
281 stats = info.source.getStat(args[1])
282 info.source.get = "sum"
283
284
285 #loop through all the stats selected
286 for stat in stats:
287
288 print "%s:" % stat.name
289 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
290 ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV")
291 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
292 ("--------------------", "------------",
293 "------------", "----", "-----", "-----", "-----", "----------")
294 #loop through all the selected runs
295 for run in runs:
296 info.display_run = run.run;
297 runTicks = info.source.retTicks([ run ])
298 #throw away the first one, it's 0
299 runTicks.pop(0)
300 info.globalTicks = runTicks
301 avg = 0
302 stdev = 0
303 numoutsideavg = 0
304 numoutside1std = 0
305 numoutside2std = 0
306 pairRunTicks = []
307 if float(stat) == 1e300*1e300:
308 continue
309 for t in range(0, len(runTicks)-(merge-1), merge):
310 tempPair = []
311 for p in range(0,merge):
312 tempPair.append(runTicks[t+p])
313 pairRunTicks.append(tempPair)
314 #loop through all the various ticks for each run
315 for tick in pairRunTicks:
316 info.globalTicks = tick
317 avg += float(stat)
318 avg /= len(pairRunTicks)
319 for tick in pairRunTicks:
320 info.globalTicks = tick
321 val = float(stat)
322 stdev += pow((val-avg),2)
323 stdev = math.sqrt(stdev / len(pairRunTicks))
324 for tick in pairRunTicks:
325 info.globalTicks = tick
326 val = float(stat)
327 if (val < (avg * .9)) or (val > (avg * 1.1)):
328 numoutsideavg += 1
329 if (val < (avg - stdev)) or (val > (avg + stdev)):
330 numoutside1std += 1
331 if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))):
332 numoutside2std += 1
333 if avg > 1000:
334 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
335 (run.name, "%.1f" % avg, "%.1f" % stdev,
336 "%d" % numoutsideavg, "%d" % numoutside1std,
337 "%d" % numoutside2std, "%d" % len(pairRunTicks),
338 "%.3f" % (stdev/avg*100))
339 elif avg > 100:
340 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
341 (run.name, "%.1f" % avg, "%.1f" % stdev,
342 "%d" % numoutsideavg, "%d" % numoutside1std,
343 "%d" % numoutside2std, "%d" % len(pairRunTicks),
344 "%.5f" % (stdev/avg*100))
345 else:
346 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
347 (run.name, "%.5f" % avg, "%.5f" % stdev,
348 "%d" % numoutsideavg, "%d" % numoutside1std,
349 "%d" % numoutside2std, "%d" % len(pairRunTicks),
350 "%.7f" % (stdev/avg*100))
351 return
352
353 if command == 'stats':
354 if len(args) == 0:
355 info.source.listStats()
356 elif len(args) == 1:
357 info.source.listStats(args[0])
358 else:
359 raise CommandException
360
361 return
362
363 if command == 'stat':
364 if len(args) != 1:
365 raise CommandException
366
367 stats = info.source.getStat(args[0])
368 for stat in stats:
369 if options.graph:
370 graphdata(runs, options, stat.name, stat.name, stat)
371 else:
372 if options.ticks:
373 print 'only displaying sample %s' % options.ticks
374 info.globalTicks = [ int(x) for x in options.ticks.split() ]
375
376 if options.binned:
377 print 'kernel ticks'
378 stat.bins = 'kernel'
379 printdata(runs, stat)
380
381 print 'idle ticks'
382 stat.bins = 'idle'
383 printdata(runs, stat)
384
385 print 'user ticks'
386 stat.bins = 'user'
387 printdata(runs, stat)
388
389 print 'interrupt ticks'
390 stat.bins = 'interrupt'
391 printdata(runs, stat)
392
393 print 'total ticks'
394
395 stat.bins = None
396 print stat.name
397 printdata(runs, stat)
398 return
399
400 if command == 'formula':
401 if len(args) != 1:
402 raise CommandException
403
404 stats = eval(args[0])
405 for stat in stats:
406 if options.graph:
407 graphdata(runs, options, stat.name, stat.name, stat)
408 else:
409 if options.binned:
410 print 'kernel ticks'
411 stat.bins = 'kernel'
412 printdata(runs, stat)
413
414 print 'idle ticks'
415 stat.bins = 'idle'
416 printdata(runs, stat)
417
418 print 'user ticks'
419 stat.bins = 'user'
420 printdata(runs, stat)
421
422 print 'interrupt ticks'
423 stat.bins = 'interrupt'
424 printdata(runs, stat)
425
426 print 'total ticks'
427
428 stat.bins = None
429 print args[0]
430 printdata(runs, stat)
431 return
432
433 if command == 'bins':
434 if len(args) == 0:
435 info.source.listBins()
436 elif len(args) == 1:
437 info.source.listBins(args[0])
438 else:
439 raise CommandException
440
441 return
442
443 if command == 'formulas':
444 if len(args) == 0:
445 info.source.listFormulas()
446 elif len(args) == 1:
447 info.source.listFormulas(args[0])
448 else:
449 raise CommandException
450
451 return
452
453 if command == 'samples':
454 if len(args):
455 raise CommandException
456
457 info.source.listTicks(runs)
458 return
459
460 if len(args):
461 raise CommandException
462
463 system = info.source.__dict__[options.system]
464
465 if command == 'usertime':
466 import copy
467 kernel = copy.copy(system.full0.numCycles)
468 kernel.bins = 'kernel'
469
470 user = copy.copy(system.full0.numCycles)
471 user.bins = 'user'
472
473 if options.graph:
474 graphdata(runs, options, 'usertime', 'User Fraction',
475 user / system.full0.numCycles)
476 else:
477 printdata(runs, user / system.full0.numCycles)
478 return
479
480 if command == 'ticks':
481 if options.binned:
482 print 'kernel ticks'
483 system.full0.numCycles.bins = 'kernel'
484 printdata(runs, system.full0.numCycles)
485
486 print 'idle ticks'
487 system.full0.numCycles.bins = 'idle'
488 printdata(runs, system.full0.numCycles)
489
490 print 'user ticks'
491 system.full0.numCycles.bins = 'user'
492 printdata(runs, system.full0.numCycles)
493
494 print 'total ticks'
495
496 system.full0.numCycles.bins = None
497 printdata(runs, system.full0.numCycles)
498 return
499
500 if command == 'packets':
501 packets = system.tsunami.etherdev0.rxPackets
502 if options.graph:
503 graphdata(runs, options, 'packets', 'Packets', packets)
504 else:
505 printdata(runs, packets)
506 return
507
508 if command == 'ppt' or command == 'tpp':
509 ppt = system.tsunami.etherdev0.rxPackets / sim_ticks
510 printdata(runs, ppt, command == 'tpp')
511 return
512
513 if command == 'pps':
514 pps = system.tsunami.etherdev0.rxPackets / sim_seconds
515 if options.graph:
516 graphdata(runs, options, 'pps', 'Packets/s', pps)
517 else:
518 printdata(runs, pps)
519 return
520
521 if command == 'bpt' or command == 'tpb':
522 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
523 bpt = bytes / sim_ticks * 8
524 if options.graph:
525 graphdata(runs, options, 'bpt', 'bps / Hz', bpt)
526 else:
527 printdata(runs, bpt, command == 'tpb')
528 return
529
530 if command == 'bptb' or command == 'tpbb':
531 bytes = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
532
533 print 'kernel stats'
534 bytes.bins = 'kernel'
535 printdata(runs, bytes / ticks)
536
537 print 'idle stats'
538 bytes.bins = 'idle'
539 printdata(runs, bytes / ticks)
540
541 print 'user stats'
542 bytes.bins = 'user'
543 printdata(runs, bytes / ticks)
544
545 return
546
547 if command == 'bytes':
548 stat = system.tsunami.etherdev0.rxBytes + system.tsunami.etherdev0.txBytes
549
550 if options.binned:
551 print '%s kernel stats' % stat.name
552 stat.bins = 'kernel'
553 printdata(runs, stat)
554
555 print '%s idle stats' % stat.name
556 stat.bins = 'idle'
557 printdata(runs, stat)
558
559 print '%s user stats' % stat.name
560 stat.bins = 'user'
561 printdata(runs, stat)
562
563 print '%s total stats' % stat.name
564 stat.bins = None
565
566 printdata(runs, stat)
567 return
568
569 if command == 'rxbps':
570 gbps = system.tsunami.etherdev0.rxBandwidth / 1e9
571 if options.graph:
572 graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps)
573 else:
574 printdata(runs, gbps)
575 return
576
577 if command == 'txbps':
578 gbps = system.tsunami.etherdev0.txBandwidth / 1e9
579 if options.graph:
580 graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps)
581 else:
582 printdata(runs, gbps)
583 return
584
585 if command == 'bps':
586 rxbps = system.tsunami.etherdev0.rxBandwidth
587 txbps = system.tsunami.etherdev0.txBandwidth
588 gbps = (rxbps + txbps) / 1e9
589 if options.graph:
590 graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps)
591 else:
592 printdata(runs, gbps)
593 return
594
595 if command == 'misses':
596 stat = system.l2.overall_mshr_misses
597 if options.binned:
598 print '%s kernel stats' % stat.name
599 stat.bins = 'kernel'
600 printdata(runs, stat)
601
602 print '%s idle stats' % stat.name
603 stat.bins = 'idle'
604 printdata(runs, stat)
605
606 print '%s user stats' % stat.name
607 stat.bins = 'user'
608 printdata(runs, stat)
609
610 print '%s total stats' % stat.name
611
612 stat.bins = None
613 if options.graph:
614 graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat)
615 else:
616 printdata(runs, stat)
617 return
618
619 if command == 'mpkb':
620 misses = system.l2.overall_mshr_misses
621 rxbytes = system.tsunami.etherdev0.rxBytes
622 txbytes = system.tsunami.etherdev0.txBytes
623
624 if options.binned:
625 print 'mpkb kernel stats'
626 misses.bins = 'kernel'
627 mpkb = misses / ((rxbytes + txbytes) / 1024)
628 printdata(runs, mpkb)
629
630 print 'mpkb idle stats'
631 misses.bins = 'idle'
632 mpkb = misses / ((rxbytes + txbytes) / 1024)
633 printdata(runs, mpkb)
634
635 print 'mpkb user stats'
636 misses.bins = 'user'
637 mpkb = misses / ((rxbytes + txbytes) / 1024)
638 printdata(runs, mpkb)
639
640 print 'mpkb total stats'
641
642 mpkb = misses / ((rxbytes + txbytes) / 1024)
643 misses.bins = None
644 if options.graph:
645 graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb)
646 else:
647 printdata(runs, mpkb)
648 return
649
650 if command == 'ipkb':
651 interrupts = system.full0.kern.faults[4]
652 rxbytes = system.tsunami.etherdev0.rxBytes
653 txbytes = system.tsunami.etherdev0.txBytes
654
655 if options.binned:
656 print 'ipkb kernel stats'
657 interrupts.bins = 'kernel'
658 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
659 printdata(runs, ipkb)
660
661 print 'ipkb idle stats'
662 interrupts.bins = 'idle'
663 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
664 printdata(runs, ipkb)
665
666 print 'ipkb user stats'
667 interrupts.bins = 'user'
668 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
669 printdata(runs, ipkb)
670
671 print 'ipkb total stats'
672
673 ipkb = interrupts / ((rxbytes + txbytes) / 1024)
674 interrupts.bins = None
675 if options.graph:
676 graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb)
677 else:
678 printdata(runs, ipkb)
679 return
680
681 if command == 'execute':
682 printdata(runs, system.full0.ISSUE__count)
683 return
684
685 if command == 'commit':
686 printdata(runs, system.full0.COM__count)
687 return
688
689 if command == 'fetch':
690 printdata(runs, system.full0.FETCH__count)
691 return
692
693 if command == 'bpp':
694 ed = system.tsunami.etherdev0
695 bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets)
696 if options.graph:
697 graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp)
698 else:
699 printdata(runs, bpp)
700 return
701
702 if command == 'rxbpp':
703 bpp = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.rxPackets
704 if options.graph:
705 graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp)
706 else:
707 printdata(runs, bpp)
708 return
709
710 if command == 'txbpp':
711 bpp = system.tsunami.etherdev0.txBytes / system.tsunami.etherdev0.txPackets
712 if options.graph:
713 graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp)
714 else:
715 printdata(runs, bpp)
716 return
717
718 if command == 'rtp':
719 rtp = system.tsunami.etherdev0.rxPackets / system.tsunami.etherdev0.txPackets
720 if options.graph:
721 graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp)
722 else:
723 printdata(runs, rtp)
724 return
725
726 if command == 'rtb':
727 rtb = system.tsunami.etherdev0.rxBytes / system.tsunami.etherdev0.txBytes
728 if options.graph:
729 graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb)
730 else:
731 printdata(runs, rtb)
732 return
733
734 raise CommandException
735
736
737class Options: pass
738
739if __name__ == '__main__':
740 import getpass
741
742 options = Options()
743 options.host = 'zizzer.pool'
744 options.db = None
745 options.passwd = ''
746 options.user = getpass.getuser()
747 options.runs = None
748 options.system = 'client'
749 options.get = None
750 options.binned = False
751 options.graph = False
752 options.ticks = False
753
754 opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:')
755 for o,a in opts:
756 if o == '-B':
757 options.binned = True
758 if o == '-E':
759 printval.mode = 'E'
760 if o == '-F':
761 printval.mode = 'F'
762 if o == '-G':
763 options.graph = True;
764 if o == '-d':
765 options.db = a
766 if o == '-g':
767 options.get = a
768 if o == '-h':
769 options.host = a
770 if o == '-p':
771 options.passwd = getpass.getpass()
772 if o == '-r':
773 options.runs = a
774 if o == '-u':
775 options.user = a
776 if o == '-s':
777 options.system = a
778 if o == '-T':
779 options.ticks = a
780
781 if len(args) == 0:
782 usage()
783
784 command = args[0]
785 args = args[1:]
786
787 try:
788 commands(options, command, args)
789 except CommandException:
790 usage()