@@ -418,33 +418,32 @@ def run_benchmarks(driver):
418
418
"""
419
419
# Set a constant hash seed. Some tests are currently sensitive to
420
420
# fluctuations in the number of hash collisions.
421
- #
422
- # FIXME: This should only be set in the environment of the child process
423
- # that runs the tests.
424
421
os .environ ["SWIFT_DETERMINISTIC_HASHING" ] = "1"
425
422
426
- log = driver .args .output_dir
427
- output = []
428
- headings = ['#' , 'TEST' , 'SAMPLES' , 'MIN(μs)' , 'MAX(μs)' , 'MEAN(μs)' ,
429
- 'SD(μs)' , 'MEDIAN(μs)' , 'MAX_RSS(B)' ]
430
423
line_format = '{:>3} {:<25} {:>7} {:>7} {:>7} {:>8} {:>6} {:>10} {:>10}'
431
- if log :
432
- print (line_format .format (* headings ))
433
- else :
434
- print (',' .join (headings ))
424
+ format = (
425
+ (lambda values : ',' .join (values )) # CSV
426
+ if (driver .args .output_dir is None ) else
427
+ (lambda values : line_format .format (* values ))) # justified columns
428
+
429
+ def console_log (values ):
430
+ print (format (values ))
431
+
432
+ console_log (['#' , 'TEST' , 'SAMPLES' , 'MIN(μs)' , 'MAX(μs)' , # header
433
+ 'MEAN(μs)' , 'SD(μs)' , 'MEDIAN(μs)' , 'MAX_RSS(B)' ])
434
+
435
+ def result_values (r ):
436
+ return map (str , [r .test_num , r .name , r .num_samples , r .min , r .max ,
437
+ int (r .mean ), int (r .sd ), r .median , r .max_rss ])
438
+
439
+ results = []
435
440
for test in driver .tests :
436
- r = driver .run_independent_samples (test )
437
- test_output = map (str , [
438
- r .test_num , r .name , r .num_samples , r .min , r .max , int (r .mean ),
439
- int (r .sd ), r .median , r .max_rss ])
440
- if log :
441
- print (line_format .format (* test_output ))
442
- else :
443
- print (',' .join (test_output ))
444
- output .append (test_output )
441
+ result = result_values (driver .run_independent_samples (test ))
442
+ console_log (result )
443
+ results .append (result )
445
444
446
445
print ('\n Total performance tests executed: {0}' .format (len (driver .tests )))
447
- csv_log = '\n ' .join ([',' .join (l ) for l in output ]) + '\n '
446
+ csv_log = '\n ' .join ([',' .join (r ) for r in results ]) + '\n '
448
447
return csv_log
449
448
450
449
0 commit comments