stats.py revision 1308
112838Sgabeblack@google.com#!/usr/bin/env python 212838Sgabeblack@google.comfrom __future__ import division 312838Sgabeblack@google.comimport re, sys 412838Sgabeblack@google.com 512838Sgabeblack@google.comdef usage(): 612838Sgabeblack@google.com print '''\ 712838Sgabeblack@google.comUsage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p] 812838Sgabeblack@google.com [-s <system>] [-r <runs> ] [-u <username>] <command> [command args] 912838Sgabeblack@google.com''' % sys.argv[0] 1012838Sgabeblack@google.com sys.exit(1) 1112838Sgabeblack@google.com 1212838Sgabeblack@google.comdef getopts(list, flags): 1312838Sgabeblack@google.com import getopt 1412838Sgabeblack@google.com try: 1512838Sgabeblack@google.com opts, args = getopt.getopt(list, flags) 1612838Sgabeblack@google.com except getopt.GetoptError: 1712838Sgabeblack@google.com usage() 1812838Sgabeblack@google.com 1912838Sgabeblack@google.com return opts, args 2012838Sgabeblack@google.com 2112838Sgabeblack@google.comdef printval(name, value, invert = False): 2212838Sgabeblack@google.com if invert and value != 0.0: 2312838Sgabeblack@google.com value = 1 / value 2412838Sgabeblack@google.com 2512838Sgabeblack@google.com if value == (1e300*1e300): 2612838Sgabeblack@google.com return 2712838Sgabeblack@google.com 2812838Sgabeblack@google.com if printval.mode == 'G': 2912838Sgabeblack@google.com print '%s: %g' % (name, value) 3012838Sgabeblack@google.com elif printval.mode != 'F' and value > 1e6: 3112838Sgabeblack@google.com print '%s: %0.5e' % (name, value) 3212838Sgabeblack@google.com else: 3312838Sgabeblack@google.com print '%s: %f' % (name, value) 3412838Sgabeblack@google.com 3512838Sgabeblack@google.comprintval.mode = 'G' 3612838Sgabeblack@google.com 3712838Sgabeblack@google.comdef unique(list): 3812838Sgabeblack@google.com set = {} 3912838Sgabeblack@google.com map(set.__setitem__, list, []) 4012838Sgabeblack@google.com return set.keys() 4112838Sgabeblack@google.com 4212838Sgabeblack@google.comdef graphdata68(runs, options, tag, label, value): 4312838Sgabeblack@google.com import info 4412838Sgabeblack@google.com configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 4512838Sgabeblack@google.com benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ] 4612838Sgabeblack@google.com dmas = [ 'x' ] 4712838Sgabeblack@google.com caches = [ '2', '4' ] 4812838Sgabeblack@google.com 4912838Sgabeblack@google.com names = [] 5012838Sgabeblack@google.com 5112838Sgabeblack@google.com bench_system = { 5212838Sgabeblack@google.com 'm' : 'client', 5312838Sgabeblack@google.com 's' : 'client', 5412838Sgabeblack@google.com 'snt' : 'client', 5512838Sgabeblack@google.com 'nb1' : 'server', 5612838Sgabeblack@google.com 'nb2' : 'server', 5712838Sgabeblack@google.com 'nt1' : 'server', 5812838Sgabeblack@google.com 'nt2' : 'server', 5912838Sgabeblack@google.com 'w1' : 'server', 6012838Sgabeblack@google.com 'w2' : 'server', 6112838Sgabeblack@google.com 'w3' : 'server', 6212838Sgabeblack@google.com 'w4' : 'server', 6312838Sgabeblack@google.com 'w1s' : 'server', 6412838Sgabeblack@google.com 'w2s' : 'server', 6512838Sgabeblack@google.com 'w3s' : 'server', 6612939Sgabeblack@google.com 'ns' : 'natbox', 6712939Sgabeblack@google.com 'nm' : 'natbox', 6812939Sgabeblack@google.com 'nw1' : 'natbox', 6912939Sgabeblack@google.com 'nw2' : 'natbox', 7012939Sgabeblack@google.com 'nw3' : 'natbox' 7112939Sgabeblack@google.com } 7212939Sgabeblack@google.com 7312939Sgabeblack@google.com for bench in benchmarks: 7412939Sgabeblack@google.com if bench_system[bench] != options.system: 7512939Sgabeblack@google.com continue 7612939Sgabeblack@google.com 7712939Sgabeblack@google.com for dma in dmas: 7812939Sgabeblack@google.com for cache in caches: 7912939Sgabeblack@google.com names.append([bench, dma, cache]) 8012939Sgabeblack@google.com 8112939Sgabeblack@google.com for bench,dma,cache in names: 8212939Sgabeblack@google.com base = '%s.%s.%s' % (bench, dma, cache) 8312939Sgabeblack@google.com fname = 'data/%s.%s.68.dat' % (tag, base) 8412939Sgabeblack@google.com f = open(fname, 'w') 8512939Sgabeblack@google.com print >>f, '#set TITLE = ' 8612939Sgabeblack@google.com print >>f, '#set ylbl = %s' % label 8712939Sgabeblack@google.com #print >>f, '#set sublabels = %s' % ' '.join(configs) 8812939Sgabeblack@google.com print >>f, '#set sublabels = ste hte htd ocm occ ocs' 8912838Sgabeblack@google.com 9012838Sgabeblack@google.com for speed,freq in zip(['s', '6', '8', 'q'],['4GHz', '6GHz','8GHz', '10GHz']): 9112838Sgabeblack@google.com print >>f, '"%s"' % freq, 9212838Sgabeblack@google.com for conf in configs: 9312838Sgabeblack@google.com name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 9412838Sgabeblack@google.com run = info.source.allRunNames[name] 9512838Sgabeblack@google.com info.display_run = run.run; 9612838Sgabeblack@google.com val = float(value) 9712838Sgabeblack@google.com if val == 1e300*1e300: 9812838Sgabeblack@google.com print >>f, 0.0, 9912838Sgabeblack@google.com else: 10012838Sgabeblack@google.com print >>f, "%f" % val, 10112838Sgabeblack@google.com print >>f 10212838Sgabeblack@google.com f.close() 10312838Sgabeblack@google.com 10412838Sgabeblack@google.comdef graphdata(runs, options, tag, label, value): 10512838Sgabeblack@google.com if options.graph68: 10612838Sgabeblack@google.com graphdata68(runs, options, tag, label, value) 10712838Sgabeblack@google.com return 10812838Sgabeblack@google.com 10912838Sgabeblack@google.com import info 11012838Sgabeblack@google.com configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 11112838Sgabeblack@google.com #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'nt2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'nw2', 'nw3' ] 11212838Sgabeblack@google.com #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'w1', 'w2', 'w3', 'ns', 'nm', 'w1s' ] 11312838Sgabeblack@google.com benchmarks = [ 'm', 's', 'nb1', 'nb2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'snt' ] 11412838Sgabeblack@google.com #dmas = [ 'x', 'd', 'b' ] 11512838Sgabeblack@google.com dmas = [ 'x' ] 11612838Sgabeblack@google.com caches = [ '2', '4' ] 11712838Sgabeblack@google.com 11812838Sgabeblack@google.com names = [] 11912838Sgabeblack@google.com 12012838Sgabeblack@google.com bench_system = { 12112838Sgabeblack@google.com 'm' : 'client', 12212838Sgabeblack@google.com 's' : 'client', 12312838Sgabeblack@google.com 'snt' : 'client', 12412838Sgabeblack@google.com 'nb1' : 'server', 12512838Sgabeblack@google.com 'nb2' : 'server', 12612838Sgabeblack@google.com 'nt1' : 'server', 12712838Sgabeblack@google.com 'nt2' : 'server', 12812838Sgabeblack@google.com 'w1' : 'server', 12912838Sgabeblack@google.com 'w2' : 'server', 13012838Sgabeblack@google.com 'w3' : 'server', 13112838Sgabeblack@google.com 'w4' : 'server', 13212838Sgabeblack@google.com 'w1s' : 'server', 13312838Sgabeblack@google.com 'w2s' : 'server', 13412838Sgabeblack@google.com 'w3s' : 'server', 13512838Sgabeblack@google.com 'ns' : 'natbox', 13612838Sgabeblack@google.com 'nm' : 'natbox', 13712838Sgabeblack@google.com 'nw1' : 'natbox', 13812838Sgabeblack@google.com 'nw2' : 'natbox', 13912838Sgabeblack@google.com 'nw3' : 'natbox' 14012838Sgabeblack@google.com } 14112838Sgabeblack@google.com 14212838Sgabeblack@google.com for bench in benchmarks: 14312838Sgabeblack@google.com if bench_system[bench] != options.system: 14412838Sgabeblack@google.com continue 14512838Sgabeblack@google.com 14612838Sgabeblack@google.com for dma in dmas: 14712838Sgabeblack@google.com for cache in caches: 14812838Sgabeblack@google.com names.append([bench, dma, cache]) 14912838Sgabeblack@google.com 15012838Sgabeblack@google.com for bench,dma,cache in names: 15112838Sgabeblack@google.com base = '%s.%s.%s' % (bench, dma, cache) 15212838Sgabeblack@google.com fname = 'data/%s.%s.dat' % (tag, base) 15312838Sgabeblack@google.com f = open(fname, 'w') 15412838Sgabeblack@google.com print >>f, '#set TITLE = ' 15512838Sgabeblack@google.com print >>f, '#set ylbl = %s' % label 15612838Sgabeblack@google.com #print >>f, '#set sublabels = %s' % ' '.join(configs) 15712838Sgabeblack@google.com print >>f, '#set sublabels = ste hte htd ocm occ ocs' 15812838Sgabeblack@google.com 15912838Sgabeblack@google.com for speed,freq in zip(['s', 'q'],['4GHz','10GHz']): 16012838Sgabeblack@google.com print >>f, '"%s"' % freq, 16112838Sgabeblack@google.com for conf in configs: 16212838Sgabeblack@google.com name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 16312838Sgabeblack@google.com run = info.source.allRunNames[name] 16412838Sgabeblack@google.com info.display_run = run.run; 16512838Sgabeblack@google.com val = float(value) 16612838Sgabeblack@google.com if val == 1e300*1e300: 16712838Sgabeblack@google.com print >>f, 0.0, 16812838Sgabeblack@google.com else: 16912838Sgabeblack@google.com print >>f, "%f" % val, 17012838Sgabeblack@google.com print >>f 17112838Sgabeblack@google.com f.close() 17212838Sgabeblack@google.com 17312838Sgabeblack@google.comdef printdata(runs, value, invert = False): 17412838Sgabeblack@google.com import info 17512838Sgabeblack@google.com for run in runs: 17612838Sgabeblack@google.com info.display_run = run.run; 17712838Sgabeblack@google.com val = float(value) 17812838Sgabeblack@google.com printval(run.name, val) 17912838Sgabeblack@google.com 18012838Sgabeblack@google.comclass CommandException(Exception): 18112838Sgabeblack@google.com pass 18212838Sgabeblack@google.com 18312838Sgabeblack@google.comdef commands(options, command, args): 18412838Sgabeblack@google.com if command == 'database': 18512838Sgabeblack@google.com if len(args) == 0: raise CommandException 18612838Sgabeblack@google.com 18712838Sgabeblack@google.com import dbinit 18812838Sgabeblack@google.com mydb = dbinit.MyDB(options) 18912838Sgabeblack@google.com 19012838Sgabeblack@google.com if args[0] == 'drop': 19112838Sgabeblack@google.com if len(args) > 2: raise CommandException 19212838Sgabeblack@google.com mydb.admin() 19312838Sgabeblack@google.com mydb.drop() 19412838Sgabeblack@google.com if len(args) == 2 and args[1] == 'init': 19512838Sgabeblack@google.com mydb.create() 19612838Sgabeblack@google.com mydb.connect() 19712838Sgabeblack@google.com mydb.populate() 19812838Sgabeblack@google.com mydb.close() 19912838Sgabeblack@google.com return 20012838Sgabeblack@google.com 20112838Sgabeblack@google.com if args[0] == 'init': 20212838Sgabeblack@google.com if len(args) > 1: raise CommandException 20312838Sgabeblack@google.com mydb.admin() 20412838Sgabeblack@google.com mydb.create() 20512838Sgabeblack@google.com mydb.connect() 20612838Sgabeblack@google.com mydb.populate() 20712838Sgabeblack@google.com mydb.close() 20812838Sgabeblack@google.com return 20912838Sgabeblack@google.com 21012838Sgabeblack@google.com if args[0] == 'clean': 21112838Sgabeblack@google.com if len(args) > 1: raise CommandException 21212838Sgabeblack@google.com mydb.connect() 21312838Sgabeblack@google.com mydb.clean() 21412838Sgabeblack@google.com return 21512838Sgabeblack@google.com 21612838Sgabeblack@google.com raise CommandException 21712838Sgabeblack@google.com 21812838Sgabeblack@google.com import db, info 21912838Sgabeblack@google.com info.source = db.Database() 22012838Sgabeblack@google.com info.source.host = options.host 22112838Sgabeblack@google.com info.source.db = options.db 22212838Sgabeblack@google.com info.source.passwd = options.passwd 22312838Sgabeblack@google.com info.source.user = options.user 22412838Sgabeblack@google.com info.source.connect() 22512838Sgabeblack@google.com info.source.update_dict(globals()) 22612838Sgabeblack@google.com 22712838Sgabeblack@google.com if type(options.get) is str: 22812838Sgabeblack@google.com info.source.get = options.get 22912838Sgabeblack@google.com 23012838Sgabeblack@google.com if options.runs is None: 23112838Sgabeblack@google.com runs = info.source.allRuns 23212838Sgabeblack@google.com else: 23312838Sgabeblack@google.com rx = re.compile(options.runs) 23412838Sgabeblack@google.com runs = [] 23512838Sgabeblack@google.com for run in info.source.allRuns: 23612838Sgabeblack@google.com if rx.match(run.name): 23712838Sgabeblack@google.com runs.append(run) 23812838Sgabeblack@google.com 23912838Sgabeblack@google.com info.display_run = runs[0].run 24012838Sgabeblack@google.com 24112838Sgabeblack@google.com if command == 'runs': 24212838Sgabeblack@google.com user = None 24312838Sgabeblack@google.com opts, args = getopts(args, '-u') 24412838Sgabeblack@google.com if len(args): 24512838Sgabeblack@google.com raise CommandException 24612838Sgabeblack@google.com for o,a in opts: 24712838Sgabeblack@google.com if o == '-u': 24812838Sgabeblack@google.com user = a 24912838Sgabeblack@google.com info.source.listRuns(user) 25012838Sgabeblack@google.com return 25112838Sgabeblack@google.com 25212838Sgabeblack@google.com if command == 'stats': 25312838Sgabeblack@google.com if len(args) == 0: 25412838Sgabeblack@google.com info.source.listStats() 25512838Sgabeblack@google.com elif len(args) == 1: 25612838Sgabeblack@google.com info.source.listStats(args[0]) 25712838Sgabeblack@google.com else: 25812838Sgabeblack@google.com raise CommandException 25912838Sgabeblack@google.com 26012838Sgabeblack@google.com return 26112838Sgabeblack@google.com 26212838Sgabeblack@google.com if command == 'stat': 26312838Sgabeblack@google.com if len(args) != 1: 26412838Sgabeblack@google.com raise CommandException 26512838Sgabeblack@google.com 26612838Sgabeblack@google.com stats = info.source.getStat(args[0]) 26712838Sgabeblack@google.com for stat in stats: 26812838Sgabeblack@google.com if options.graph: 26912838Sgabeblack@google.com graphdata(runs, options, stat.name, stat.name, stat) 27012838Sgabeblack@google.com else: 27112838Sgabeblack@google.com if options.ticks: 27212838Sgabeblack@google.com print 'only displaying sample %s' % options.ticks 27312838Sgabeblack@google.com stat.ticks = options.ticks 27412838Sgabeblack@google.com 27512838Sgabeblack@google.com if options.binned: 27612838Sgabeblack@google.com print 'kernel ticks' 27712838Sgabeblack@google.com stat.bins = 'kernel' 27812838Sgabeblack@google.com printdata(runs, stat) 27912838Sgabeblack@google.com 28012838Sgabeblack@google.com print 'idle ticks' 28112838Sgabeblack@google.com stat.bins = 'idle' 28212838Sgabeblack@google.com printdata(runs, stat) 28312838Sgabeblack@google.com 28412838Sgabeblack@google.com print 'user ticks' 28512838Sgabeblack@google.com stat.bins = 'user' 28612838Sgabeblack@google.com printdata(runs, stat) 28712838Sgabeblack@google.com 28812838Sgabeblack@google.com print 'interrupt ticks' 28912838Sgabeblack@google.com stat.bins = 'interrupt' 29012838Sgabeblack@google.com printdata(runs, stat) 29112838Sgabeblack@google.com 29212838Sgabeblack@google.com print 'total ticks' 29312838Sgabeblack@google.com 29412838Sgabeblack@google.com stat.bins = None 29512838Sgabeblack@google.com print stat.name 29612838Sgabeblack@google.com printdata(runs, stat) 29712838Sgabeblack@google.com return 29812838Sgabeblack@google.com 29912838Sgabeblack@google.com if command == 'formula': 30012838Sgabeblack@google.com if len(args) != 1: 30112838Sgabeblack@google.com raise CommandException 30212838Sgabeblack@google.com 30312838Sgabeblack@google.com stats = eval(args[0]) 30412899Sgabeblack@google.com for stat in stats: 30512899Sgabeblack@google.com if options.graph: 30612838Sgabeblack@google.com graphdata(runs, options, stat.name, stat.name, stat) 307 else: 308 if options.binned: 309 print 'kernel ticks' 310 stat.bins = 'kernel' 311 printdata(runs, stat) 312 313 print 'idle ticks' 314 stat.bins = 'idle' 315 printdata(runs, stat) 316 317 print 'user ticks' 318 stat.bins = 'user' 319 printdata(runs, stat) 320 321 print 'interrupt ticks' 322 stat.bins = 'interrupt' 323 printdata(runs, stat) 324 325 print 'total ticks' 326 327 stat.bins = None 328 print args[0] 329 printdata(runs, stat) 330 return 331 332 if command == 'bins': 333 if len(args) == 0: 334 info.source.listBins() 335 elif len(args) == 1: 336 info.source.listBins(args[0]) 337 else: 338 raise CommandException 339 340 return 341 342 if command == 'formulas': 343 if len(args) == 0: 344 info.source.listFormulas() 345 elif len(args) == 1: 346 info.source.listFormulas(args[0]) 347 else: 348 raise CommandException 349 350 return 351 352 if command == 'samples': 353 if len(args): 354 raise CommandException 355 356 info.source.listTicks(runs) 357 return 358 359 if len(args): 360 raise CommandException 361 362 system = info.source.__dict__[options.system] 363 364 if command == 'usertime': 365 import copy 366 kernel = copy.copy(system.full_cpu.numCycles) 367 kernel.bins = 'kernel' 368 369 user = copy.copy(system.full_cpu.numCycles) 370 user.bins = 'user' 371 372 if options.graph: 373 graphdata(runs, options, 'usertime', 'User Fraction', 374 user / system.full_cpu.numCycles) 375 else: 376 printdata(runs, user / system.full_cpu.numCycles) 377 return 378 379 if command == 'ticks': 380 if options.binned: 381 print 'kernel ticks' 382 system.full_cpu.numCycles.bins = 'kernel' 383 printdata(runs, system.full_cpu.numCycles) 384 385 print 'idle ticks' 386 system.full_cpu.numCycles.bins = 'idle' 387 printdata(runs, system.full_cpu.numCycles) 388 389 print 'user ticks' 390 system.full_cpu.numCycles.bins = 'user' 391 printdata(runs, system.full_cpu.numCycles) 392 393 print 'total ticks' 394 395 system.full_cpu.numCycles.bins = None 396 printdata(runs, system.full_cpu.numCycles) 397 return 398 399 if command == 'packets': 400 packets = system.tsunami.etherdev.rxPackets 401 if options.graph: 402 graphdata(runs, options, 'packets', 'Packets', packets) 403 else: 404 printdata(runs, packets) 405 return 406 407 if command == 'ppt' or command == 'tpp': 408 ppt = system.tsunami.etherdev.rxPackets / sim_ticks 409 printdata(runs, ppt, command == 'tpp') 410 return 411 412 if command == 'pps': 413 pps = system.tsunami.etherdev.rxPackets / sim_seconds 414 if options.graph: 415 graphdata(runs, options, 'pps', 'Packets/s', pps) 416 else: 417 printdata(runs, pps) 418 return 419 420 if command == 'bpt' or command == 'tpb': 421 bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 422 bpt = bytes / sim_ticks * 8 423 if options.graph: 424 graphdata(runs, options, 'bpt', 'bps / Hz', bpt) 425 else: 426 printdata(runs, bpt, command == 'tpb') 427 return 428 429 if command == 'bptb' or command == 'tpbb': 430 bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 431 432 print 'kernel stats' 433 bytes.bins = 'kernel' 434 printdata(runs, bytes / ticks) 435 436 print 'idle stats' 437 bytes.bins = 'idle' 438 printdata(runs, bytes / ticks) 439 440 print 'user stats' 441 bytes.bins = 'user' 442 printdata(runs, bytes / ticks) 443 444 return 445 446 if command == 'bytes': 447 stat = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 448 449 if options.binned: 450 print '%s kernel stats' % stat.name 451 stat.bins = 'kernel' 452 printdata(runs, stat) 453 454 print '%s idle stats' % stat.name 455 stat.bins = 'idle' 456 printdata(runs, stat) 457 458 print '%s user stats' % stat.name 459 stat.bins = 'user' 460 printdata(runs, stat) 461 462 print '%s total stats' % stat.name 463 stat.bins = None 464 465 printdata(runs, stat) 466 return 467 468 if command == 'rxbps': 469 gbps = system.tsunami.etherdev.rxBandwidth / 1e9 470 if options.graph: 471 graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps) 472 else: 473 printdata(runs, gbps) 474 return 475 476 if command == 'txbps': 477 gbps = system.tsunami.etherdev.txBandwidth / 1e9 478 if options.graph: 479 graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps) 480 else: 481 printdata(runs, gbps) 482 return 483 484 if command == 'bps': 485 rxbps = system.tsunami.etherdev.rxBandwidth 486 txbps = system.tsunami.etherdev.txBandwidth 487 gbps = (rxbps + txbps) / 1e9 488 if options.graph: 489 graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps) 490 else: 491 printdata(runs, gbps) 492 return 493 494 if command == 'misses': 495 stat = system.L2.overall_mshr_misses 496 if options.binned: 497 print '%s kernel stats' % stat.name 498 stat.bins = 'kernel' 499 printdata(runs, stat) 500 501 print '%s idle stats' % stat.name 502 stat.bins = 'idle' 503 printdata(runs, stat) 504 505 print '%s user stats' % stat.name 506 stat.bins = 'user' 507 printdata(runs, stat) 508 509 print '%s total stats' % stat.name 510 511 stat.bins = None 512 if options.graph: 513 graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat) 514 else: 515 printdata(runs, stat) 516 return 517 518 if command == 'mpkb': 519 misses = system.L2.overall_mshr_misses 520 rxbytes = system.tsunami.etherdev.rxBytes 521 txbytes = system.tsunami.etherdev.txBytes 522 523 if options.binned: 524 print 'mpkb kernel stats' 525 misses.bins = 'kernel' 526 mpkb = misses / ((rxbytes + txbytes) / 1024) 527 printdata(runs, mpkb) 528 529 print 'mpkb idle stats' 530 misses.bins = 'idle' 531 mpkb = misses / ((rxbytes + txbytes) / 1024) 532 printdata(runs, mpkb) 533 534 print 'mpkb user stats' 535 misses.bins = 'user' 536 mpkb = misses / ((rxbytes + txbytes) / 1024) 537 printdata(runs, mpkb) 538 539 print 'mpkb total stats' 540 541 mpkb = misses / ((rxbytes + txbytes) / 1024) 542 misses.bins = None 543 if options.graph: 544 graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb) 545 else: 546 printdata(runs, mpkb) 547 return 548 549 if command == 'ipkb': 550 interrupts = system.full_cpu.kern.faults[4] 551 rxbytes = system.tsunami.etherdev.rxBytes 552 txbytes = system.tsunami.etherdev.txBytes 553 554 if options.binned: 555 print 'ipkb kernel stats' 556 interrupts.bins = 'kernel' 557 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 558 printdata(runs, ipkb) 559 560 print 'ipkb idle stats' 561 interrupts.bins = 'idle' 562 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 563 printdata(runs, ipkb) 564 565 print 'ipkb user stats' 566 interrupts.bins = 'user' 567 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 568 printdata(runs, ipkb) 569 570 print 'ipkb total stats' 571 572 ipkb = interrupts / ((rxbytes + txbytes) / 1024) 573 interrupts.bins = None 574 if options.graph: 575 graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb) 576 else: 577 printdata(runs, ipkb) 578 return 579 580 if command == 'execute': 581 printdata(runs, system.full_cpu.ISSUE__count) 582 return 583 584 if command == 'commit': 585 printdata(runs, system.full_cpu.COM__count) 586 return 587 588 if command == 'fetch': 589 printdata(runs, system.full_cpu.FETCH__count) 590 return 591 592 if command == 'bpp': 593 ed = system.tsunami.etherdev 594 bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets) 595 if options.graph: 596 graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp) 597 else: 598 printdata(runs, bpp) 599 return 600 601 if command == 'rxbpp': 602 bpp = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.rxPackets 603 if options.graph: 604 graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp) 605 else: 606 printdata(runs, bpp) 607 return 608 609 if command == 'txbpp': 610 bpp = system.tsunami.etherdev.txBytes / system.tsunami.etherdev.txPackets 611 if options.graph: 612 graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp) 613 else: 614 printdata(runs, bpp) 615 return 616 617 if command == 'rtp': 618 rtp = system.tsunami.etherdev.rxPackets / system.tsunami.etherdev.txPackets 619 if options.graph: 620 graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp) 621 else: 622 printdata(runs, rtp) 623 return 624 625 if command == 'rtb': 626 rtb = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.txBytes 627 if options.graph: 628 graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb) 629 else: 630 printdata(runs, rtb) 631 return 632 633 raise CommandException 634 635 636class Options: pass 637 638if __name__ == '__main__': 639 import getpass 640 641 options = Options() 642 options.host = 'zizzer.pool' 643 options.db = None 644 options.passwd = '' 645 options.user = getpass.getuser() 646 options.runs = None 647 options.system = 'client' 648 options.get = None 649 options.binned = False 650 options.graph = False 651 options.graph68 = False 652 options.ticks = False 653 654 opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:') 655 for o,a in opts: 656 if o == '-6': 657 options.graph68 = True 658 if o == '-B': 659 options.binned = True 660 if o == '-E': 661 printval.mode = 'E' 662 if o == '-F': 663 printval.mode = 'F' 664 if o == '-G': 665 options.graph = True; 666 if o == '-d': 667 options.db = a 668 if o == '-g': 669 options.get = a 670 if o == '-h': 671 options.host = a 672 if o == '-p': 673 options.passwd = getpass.getpass() 674 if o == '-r': 675 options.runs = a 676 if o == '-u': 677 options.user = a 678 if o == '-s': 679 options.system = a 680 if o == '-T': 681 options.ticks = a 682 683 if len(args) == 0: 684 usage() 685 686 command = args[0] 687 args = args[1:] 688 689 try: 690 commands(options, command, args) 691 except CommandException: 692 usage() 693