@@ -295,6 +295,24 @@ def format_test_result(test_name, result):
295
295
return fmt % test_name
296
296
297
297
298
+ def cpu_count ():
299
+ # first try os.sysconf() to prevent loading the big multiprocessing module
300
+ try :
301
+ return os .sysconf ('SC_NPROCESSORS_ONLN' )
302
+ except (AttributeError , ValueError ):
303
+ pass
304
+
305
+ # try multiprocessing.cpu_count()
306
+ try :
307
+ import multiprocessing
308
+ except ImportError :
309
+ pass
310
+ else :
311
+ return multiprocessing .cpu_count ()
312
+
313
+ return None
314
+
315
+
298
316
def unload_test_modules (save_modules ):
299
317
# Unload the newly imported modules (best effort finalization)
300
318
for module in sys .modules .keys ():
@@ -617,15 +635,24 @@ def test_forever(tests=list(selected)):
617
635
618
636
def display_progress (test_index , test ):
619
637
# "[ 51/405/1] test_tcl"
620
- fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}"
621
- line = fmt .format (test_count_width , test_index , test_count ,
622
- len (bad ), test )
638
+ line = "{1:{0}}{2}" .format (test_count_width , test_index , test_count )
639
+ if bad and not pgo :
640
+ line = '{}/{}' .format (line , len (bad ))
641
+ line = '[{}]' .format (line )
642
+
643
+ # add the system load prefix: "load avg: 1.80 "
644
+ if hasattr (os , 'getloadavg' ):
645
+ load_avg_1min = os .getloadavg ()[0 ]
646
+ line = "load avg: {:.2f} {}" .format (load_avg_1min , line )
623
647
624
648
# add the timestamp prefix: "0:01:05 "
625
649
test_time = time .time () - regrtest_start_time
626
650
test_time = datetime .timedelta (seconds = int (test_time ))
627
651
line = "%s %s" % (test_time , line )
628
652
653
+ # add the test name
654
+ line = "{} {}" .format (line , test )
655
+
629
656
print (line )
630
657
sys .stdout .flush ()
631
658
@@ -638,6 +665,9 @@ def display_progress(test_index, test):
638
665
print "== " , platform .platform (aliased = True ), \
639
666
"%s-endian" % sys .byteorder
640
667
print "== " , os .getcwd ()
668
+ ncpu = cpu_count ()
669
+ if ncpu :
670
+ print "== CPU count:" , ncpu
641
671
print "Testing with flags:" , sys .flags
642
672
643
673
if randomize :
0 commit comments