|
37 | 37 | import random
|
38 | 38 | import numpy as np
|
39 | 39 |
|
40 |
| -from pandas import DataFrame |
| 40 | +from pandas import DataFrame, Series |
41 | 41 |
|
42 | 42 | from suite import REPO_PATH
|
43 | 43 |
|
|
102 | 102 | 'each iteration will yield another column in the output'
|
103 | 103 | )
|
104 | 104 | parser.add_argument('-a', '--affinity',
|
105 |
| - metavar="b", |
| 105 | + metavar="a", |
106 | 106 | dest='affinity',
|
107 | 107 | default=1,
|
108 | 108 | type=int,
|
109 | 109 | help='set processor affinity of processm by default bind to cpu/core #1 only'
|
110 | 110 | 'requires the "affinity" python module , will raise Warning otherwise' )
|
111 |
| - |
112 |
| - |
| 111 | +parser.add_argument('-u', '--burnin', |
| 112 | + metavar="u", |
| 113 | + dest='burnin', |
| 114 | + default=1, |
| 115 | + type=int, |
| 116 | + help='number of extra iteration per benchmark to perform first, then throw away. ' ) |
113 | 117 |
|
114 | 118 | def get_results_df(db, rev):
|
115 | 119 | """Takes a git commit hash and returns a Dataframe of benchmark results
|
@@ -220,42 +224,53 @@ def profile_comparative(benchmarks):
|
220 | 224 | shutil.rmtree(TMP_DIR)
|
221 | 225 |
|
222 | 226 |
|
223 |
| -def profile_head_single(benchmarks): |
| 227 | +def profile_head_single(benchmark): |
224 | 228 | results = []
|
225 | 229 |
|
226 |
| - print( "Running %d benchmarks" % len(benchmarks)) |
227 |
| - for b in benchmarks: |
| 230 | + |
| 231 | + N = args.hrepeats + args.burnin |
| 232 | + |
| 233 | + results = [] |
| 234 | + for i in range(N): |
228 | 235 | clear()
|
229 | 236 | d=dict()
|
230 |
| - sys.stdout.write('.') |
231 |
| - sys.stdout.flush() |
232 | 237 | try:
|
233 |
| - d = b.run() |
| 238 | + d = benchmark.run() |
| 239 | + |
234 | 240 | except KeyboardInterrupt:
|
235 | 241 | raise
|
236 | 242 | except Exception as e: # if a single vbench bursts into flames, don't die.
|
237 | 243 | err=""
|
238 | 244 | try:
|
239 |
| - err = d.get("traceback","") |
| 245 | + err = d.get("traceback") |
| 246 | + if err is None: |
| 247 | + err = str(e) |
240 | 248 | except:
|
241 | 249 | pass
|
242 |
| - print("%s died with:\n%s\nSkipping...\n" % (b.name, err)) |
| 250 | + print("%s died with:\n%s\nSkipping...\n" % (benchmark.name, err)) |
| 251 | + |
| 252 | + results.append(d.get('timing',np.nan)) |
243 | 253 |
|
244 |
| - d.update(dict(name=b.name)) |
245 |
| - results.append(dict(name=b.name,timing=d.get('timing',np.nan))) |
| 254 | + if results: |
| 255 | + # throw away the burn_in |
| 256 | + results = results[args.burnin:] |
| 257 | + sys.stdout.write('.') |
| 258 | + sys.stdout.flush() |
| 259 | + return Series(results, name=benchmark.name) |
246 | 260 |
|
247 |
| - print("\n\n") |
248 |
| - df = DataFrame(results) |
249 |
| - df.columns = ["name",HEAD_COL] |
250 |
| - return df.set_index("name")[HEAD_COL] |
| 261 | + # df = DataFrame(results) |
| 262 | + # df.columns = ["name",HEAD_COL] |
| 263 | + # return df.set_index("name")[HEAD_COL] |
251 | 264 |
|
252 | 265 | def profile_head(benchmarks):
|
| 266 | + print( "Performing %d benchmarks (%d runs each)" % ( len(benchmarks), args.hrepeats)) |
253 | 267 |
|
254 |
| - ss= [profile_head_single(benchmarks) for i in range(args.hrepeats)] |
| 268 | + ss= [profile_head_single(b) for b in benchmarks] |
255 | 269 |
|
256 | 270 | results = DataFrame(ss)
|
257 |
| - results.index = ["#%d" % i for i in range(len(ss))] |
258 |
| - results = results.T |
| 271 | + results.columns=[ "#%d" %i for i in range(args.hrepeats)] |
| 272 | + # results.index = ["#%d" % i for i in range(len(ss))] |
| 273 | + # results = results.T |
259 | 274 |
|
260 | 275 | shas, messages, _,_ = _parse_commit_log(None,REPO_PATH,base_commit="HEAD^")
|
261 | 276 | print_report(results,h_head=shas[-1],h_msg=messages[-1])
|
@@ -342,7 +357,11 @@ def main():
|
342 | 357 | print("CPU affinity set to %d" % args.affinity)
|
343 | 358 | except ImportError:
|
344 | 359 | import warnings
|
345 |
| - warnings.warn("The 'affinity' module is not available, results may be unreliable") |
| 360 | + print("\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"+ |
| 361 | + "The 'affinity' module is not available, results may be unreliable\n" + |
| 362 | + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n" |
| 363 | + ) |
| 364 | + time.sleep(2) |
346 | 365 |
|
347 | 366 | print("\n")
|
348 | 367 | prprint("LOG_FILE = %s" % args.log_file)
|
|
0 commit comments