stats.py (1918:0c4f083eccc8) | stats.py (1929:fb189519cb06) |
---|---|
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 --- 84 unchanged lines hidden (view full) --- 93 if args[0] == 'clean': 94 if len(args) > 1: raise CommandException 95 mydb.connect() 96 mydb.clean() 97 return 98 99 raise CommandException 100 | 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 --- 84 unchanged lines hidden (view full) --- 93 if args[0] == 'clean': 94 if len(args) > 1: raise CommandException 95 mydb.connect() 96 mydb.clean() 97 return 98 99 raise CommandException 100 |
101 import db, info 102 info.source = db.Database() 103 info.source.host = options.host 104 info.source.db = options.db 105 info.source.passwd = options.passwd 106 info.source.user = options.user 107 info.source.connect() 108 #info.source.update_dict(globals()) | 101 import db 102 source = db.Database() 103 source.host = options.host 104 source.db = options.db 105 source.passwd = options.passwd 106 source.user = options.user 107 source.connect() 108 #source.update_dict(globals()) |
109 | 109 |
110 if type(options.get) is str: 111 info.source.get = options.get | 110 if type(options.method) is str: 111 source.method = options.method |
112 113 if options.runs is None: | 112 113 if options.runs is None: |
114 runs = info.source.allRuns | 114 runs = source.allRuns |
115 else: 116 rx = re.compile(options.runs) 117 runs = [] | 115 else: 116 rx = re.compile(options.runs) 117 runs = [] |
118 for run in info.source.allRuns: | 118 for run in source.allRuns: |
119 if rx.match(run.name): 120 runs.append(run) 121 | 119 if rx.match(run.name): 120 runs.append(run) 121 |
122 info.display_run = runs[0].run 123 | |
124 if command == 'runs': 125 user = None 126 opts, args = getopts(args, '-u') 127 if len(args): 128 raise CommandException 129 for o,a in opts: 130 if o == '-u': 131 user = a | 122 if command == 'runs': 123 user = None 124 opts, args = getopts(args, '-u') 125 if len(args): 126 raise CommandException 127 for o,a in opts: 128 if o == '-u': 129 user = a |
132 info.source.listRuns(user) | 130 source.listRuns(user) |
133 return 134 135 if command == 'stats': 136 if len(args) == 0: | 131 return 132 133 if command == 'stats': 134 if len(args) == 0: |
137 info.source.listStats() | 135 source.listStats() |
138 elif len(args) == 1: | 136 elif len(args) == 1: |
139 info.source.listStats(args[0]) | 137 source.listStats(args[0]) |
140 else: 141 raise CommandException 142 143 return 144 145 if command == 'bins': 146 if len(args) == 0: | 138 else: 139 raise CommandException 140 141 return 142 143 if command == 'bins': 144 if len(args) == 0: |
147 info.source.listBins() | 145 source.listBins() |
148 elif len(args) == 1: | 146 elif len(args) == 1: |
149 info.source.listBins(args[0]) | 147 source.listBins(args[0]) |
150 else: 151 raise CommandException 152 153 return 154 155 if command == 'formulas': 156 if len(args) == 0: | 148 else: 149 raise CommandException 150 151 return 152 153 if command == 'formulas': 154 if len(args) == 0: |
157 info.source.listFormulas() | 155 source.listFormulas() |
158 elif len(args) == 1: | 156 elif len(args) == 1: |
159 info.source.listFormulas(args[0]) | 157 source.listFormulas(args[0]) |
160 else: 161 raise CommandException 162 163 return 164 165 if command == 'samples': 166 if len(args): 167 raise CommandException 168 | 158 else: 159 raise CommandException 160 161 return 162 163 if command == 'samples': 164 if len(args): 165 raise CommandException 166 |
169 info.source.listTicks(runs) | 167 source.listTicks(runs) |
170 return 171 172 if command == 'stability': 173 if len(args) < 2: 174 raise CommandException 175 176 try: 177 merge = int(args[0]) 178 except ValueError: 179 usage() | 168 return 169 170 if command == 'stability': 171 if len(args) < 2: 172 raise CommandException 173 174 try: 175 merge = int(args[0]) 176 except ValueError: 177 usage() |
180 stats = info.source.getStat(args[1]) 181 info.source.get = "sum" | 178 stats = source.getStat(args[1]) 179 source.method = 'sum' |
182 183 def disp(*args): 184 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % args 185 186 # temporary variable containing a bunch of dashes 187 d = '-' * 100 188 189 #loop through all the stats selected 190 for stat in stats: 191 print "%s:" % stat.name 192 disp("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", 193 "SAMP", "CV") 194 disp(d[:20], d[:12], d[:12], d[:4], d[:5], d[:5], d[:5], d[:10]) 195 196 #loop through all the selected runs 197 for run in runs: | 180 181 def disp(*args): 182 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % args 183 184 # temporary variable containing a bunch of dashes 185 d = '-' * 100 186 187 #loop through all the stats selected 188 for stat in stats: 189 print "%s:" % stat.name 190 disp("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", 191 "SAMP", "CV") 192 disp(d[:20], d[:12], d[:12], d[:4], d[:5], d[:5], d[:5], d[:10]) 193 194 #loop through all the selected runs 195 for run in runs: |
198 info.display_run = run.run; 199 runTicks = info.source.retTicks([ run ]) | 196 runTicks = source.retTicks([ run ]) |
200 #throw away the first one, it's 0 201 runTicks.pop(0) | 197 #throw away the first one, it's 0 198 runTicks.pop(0) |
202 info.globalTicks = runTicks | 199 source.ticks = runTicks |
203 avg = 0 204 stdev = 0 205 numoutsideavg = 0 206 numoutside1std = 0 207 numoutside2std = 0 208 pairRunTicks = [] | 200 avg = 0 201 stdev = 0 202 numoutsideavg = 0 203 numoutside1std = 0 204 numoutside2std = 0 205 pairRunTicks = [] |
209 if float(stat) == 1e300*1e300: | 206 if value(stat, run.run) == 1e300*1e300: |
210 continue 211 for t in range(0, len(runTicks)-(merge-1), merge): 212 tempPair = [] 213 for p in range(0,merge): 214 tempPair.append(runTicks[t+p]) 215 pairRunTicks.append(tempPair) 216 #loop through all the various ticks for each run 217 for tick in pairRunTicks: | 207 continue 208 for t in range(0, len(runTicks)-(merge-1), merge): 209 tempPair = [] 210 for p in range(0,merge): 211 tempPair.append(runTicks[t+p]) 212 pairRunTicks.append(tempPair) 213 #loop through all the various ticks for each run 214 for tick in pairRunTicks: |
218 info.globalTicks = tick 219 avg += float(stat) | 215 source.ticks = tick 216 avg += value(stat, run.run) |
220 avg /= len(pairRunTicks) 221 for tick in pairRunTicks: | 217 avg /= len(pairRunTicks) 218 for tick in pairRunTicks: |
222 info.globalTicks = tick 223 val = float(stat) | 219 source.ticks = tick 220 val = value(stat, run.run) |
224 stdev += pow((val-avg),2) 225 stdev = math.sqrt(stdev / len(pairRunTicks)) 226 for tick in pairRunTicks: | 221 stdev += pow((val-avg),2) 222 stdev = math.sqrt(stdev / len(pairRunTicks)) 223 for tick in pairRunTicks: |
227 info.globalTicks = tick 228 val = float(stat) | 224 source.ticks = tick 225 val = value(stat, run.run) |
229 if (val < (avg * .9)) or (val > (avg * 1.1)): 230 numoutsideavg += 1 231 if (val < (avg - stdev)) or (val > (avg + stdev)): 232 numoutside1std += 1 233 if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))): 234 numoutside2std += 1 235 if avg > 1000: 236 disp(run.name, "%.1f" % avg, "%.1f" % stdev, --- 22 unchanged lines hidden (view full) --- 259 'pps', 'bpp', 'txbpp', 'rxbpp', 260 'rtp', 'rtb' ] 261 for command in all: 262 commands(options, command, args) 263 264 if options.ticks: 265 if not options.graph: 266 print 'only displaying sample %s' % options.ticks | 226 if (val < (avg * .9)) or (val > (avg * 1.1)): 227 numoutsideavg += 1 228 if (val < (avg - stdev)) or (val > (avg + stdev)): 229 numoutside1std += 1 230 if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))): 231 numoutside2std += 1 232 if avg > 1000: 233 disp(run.name, "%.1f" % avg, "%.1f" % stdev, --- 22 unchanged lines hidden (view full) --- 256 'pps', 'bpp', 'txbpp', 'rxbpp', 257 'rtp', 'rtb' ] 258 for command in all: 259 commands(options, command, args) 260 261 if options.ticks: 262 if not options.graph: 263 print 'only displaying sample %s' % options.ticks |
267 info.globalTicks = [ int(x) for x in options.ticks.split() ] | 264 source.ticks = [ int(x) for x in options.ticks.split() ] |
268 | 265 |
269 from output import StatOutput | 266 import output |
270 271 def display(): 272 if options.graph: 273 output.graph(options.graphdir) 274 else: 275 output.display(options.binned, options.printmode) 276 277 278 if command == 'stat' or command == 'formula': 279 if len(args) != 1: 280 raise CommandException 281 282 if command == 'stat': | 267 268 def display(): 269 if options.graph: 270 output.graph(options.graphdir) 271 else: 272 output.display(options.binned, options.printmode) 273 274 275 if command == 'stat' or command == 'formula': 276 if len(args) != 1: 277 raise CommandException 278 279 if command == 'stat': |
283 stats = info.source.getStat(args[0]) | 280 stats = source.getStat(args[0]) |
284 if command == 'formula': 285 stats = eval(args[0]) 286 287 for stat in stats: | 281 if command == 'formula': 282 stats = eval(args[0]) 283 284 for stat in stats: |
288 output = StatOutput(stat.name, options.jobfile) | 285 output = output.StatOutput(stat.name, options.jobfile, source) |
289 output.stat = stat 290 output.label = stat.name 291 display() 292 293 return 294 295 if len(args): 296 raise CommandException 297 | 286 output.stat = stat 287 output.label = stat.name 288 display() 289 290 return 291 292 if len(args): 293 raise CommandException 294 |
298 system = info.source.__dict__[options.system] 299 300 from proxy import ProxyGroup 301 sim_ticks = info.source['sim_ticks'] 302 sim_seconds = info.source['sim_seconds'] 303 proxy = ProxyGroup(system = info.source[options.system]) | 295 system = source.__dict__[options.system] 296 from info import ProxyGroup 297 sim_ticks = source['sim_ticks'] 298 sim_seconds = source['sim_seconds'] 299 proxy = ProxyGroup(system = source[options.system]) |
304 system = proxy.system 305 306 etherdev = system.tsunami.etherdev0 307 bytes = etherdev.rxBytes + etherdev.txBytes 308 kbytes = bytes / 1024 309 packets = etherdev.rxPackets + etherdev.txPackets 310 bps = etherdev.rxBandwidth + etherdev.txBandwidth 311 | 300 system = proxy.system 301 302 etherdev = system.tsunami.etherdev0 303 bytes = etherdev.rxBytes + etherdev.txBytes 304 kbytes = bytes / 1024 305 packets = etherdev.rxPackets + etherdev.txPackets 306 bps = etherdev.rxBandwidth + etherdev.txBandwidth 307 |
312 output = StatOutput(command, options.jobfile) | 308 output = output.StatOutput(command, options.jobfile, source) |
313 314 if command == 'usertime': 315 import copy 316 user = copy.copy(system.full0.numCycles) 317 user.bins = 'user' 318 319 output.stat = user / system.full0.numCycles 320 output.label = 'User Fraction' --- 134 unchanged lines hidden (view full) --- 455 456 options = Options() 457 options.host = None 458 options.db = None 459 options.passwd = '' 460 options.user = getpass.getuser() 461 options.runs = None 462 options.system = 'client' | 309 310 if command == 'usertime': 311 import copy 312 user = copy.copy(system.full0.numCycles) 313 user.bins = 'user' 314 315 output.stat = user / system.full0.numCycles 316 output.label = 'User Fraction' --- 134 unchanged lines hidden (view full) --- 451 452 options = Options() 453 options.host = None 454 options.db = None 455 options.passwd = '' 456 options.user = getpass.getuser() 457 options.runs = None 458 options.system = 'client' |
463 options.get = None | 459 options.method = None |
464 options.binned = False 465 options.graph = False 466 options.ticks = False 467 options.printmode = 'G' 468 jobfilename = 'Test.py' 469 options.jobfile = None 470 options.all = False 471 | 460 options.binned = False 461 options.graph = False 462 options.ticks = False 463 options.printmode = 'G' 464 jobfilename = 'Test.py' 465 options.jobfile = None 466 options.all = False 467 |
472 opts, args = getopts(sys.argv[1:], '-BEFG:Jad:g:h:j:pr:s:u:T:') | 468 opts, args = getopts(sys.argv[1:], '-BEFJad:g:h:j:m:pr:s:u:T:') |
473 for o,a in opts: 474 if o == '-B': 475 options.binned = True 476 if o == '-E': 477 options.printmode = 'E' 478 if o == '-F': 479 options.printmode = 'F' | 469 for o,a in opts: 470 if o == '-B': 471 options.binned = True 472 if o == '-E': 473 options.printmode = 'E' 474 if o == '-F': 475 options.printmode = 'F' |
480 if o == '-G': 481 options.get = a | |
482 if o == '-a': 483 options.all = True 484 if o == '-d': 485 options.db = a 486 if o == '-g': 487 options.graph = True; 488 options.graphdir = a 489 if o == '-h': 490 options.host = a 491 if o == '-J': 492 jobfilename = None 493 if o == '-j': 494 jobfilename = a | 476 if o == '-a': 477 options.all = True 478 if o == '-d': 479 options.db = a 480 if o == '-g': 481 options.graph = True; 482 options.graphdir = a 483 if o == '-h': 484 options.host = a 485 if o == '-J': 486 jobfilename = None 487 if o == '-j': 488 jobfilename = a |
489 if o == '-m': 490 options.method = a |
|
495 if o == '-p': 496 options.passwd = getpass.getpass() 497 if o == '-r': 498 options.runs = a 499 if o == '-u': 500 options.user = a 501 if o == '-s': 502 options.system = a --- 26 unchanged lines hidden --- | 491 if o == '-p': 492 options.passwd = getpass.getpass() 493 if o == '-r': 494 options.runs = a 495 if o == '-u': 496 options.user = a 497 if o == '-s': 498 options.system = a --- 26 unchanged lines hidden --- |