From patchwork Sat May 24 19:10:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: run-test: '--time' option provide more details to user From: Anurag Goel X-Patchwork-Id: 4859 Message-Id: <0c6ee6403d787f8eb08f.1400958641@ubuntu.ubuntu-domain> To: mercurial-devel@selenic.com Date: Sun, 25 May 2014 00:40:41 +0530 # HG changeset patch # User anuraggoel # Date 1400958116 -19800 # Sun May 25 00:31:56 2014 +0530 # Node ID 0c6ee6403d787f8eb08fe01550f2e9e0aa637c26 # Parent 883e268cb860c0ea2eb0faa94114e11c3a4a3893 run-test: '--time' option provide more details to user 'time.time()' module can only be used to calculate 'real' time taken by a process. Therefore, I switched it to 'os.times()' module which helps in getting additional info like "Total number of CPU-seconds that the process spent in kernel mode" and "Total number of CPU-seconds that the process spent in user mode". diff -r 883e268cb860 -r 0c6ee6403d78 tests/run-tests.py --- a/tests/run-tests.py Wed Apr 30 18:40:20 2014 -0700 +++ b/tests/run-tests.py Sun May 25 00:31:56 2014 +0530 @@ -551,11 +551,11 @@ def outputtimes(options): vlog('# Producing time report') - times.sort(key=lambda t: (t[1], t[0]), reverse=True) - cols = '%7.3f %s' - print '\n%-7s %s' % ('Time', 'Test') - for test, timetaken in times: - print cols % (timetaken, test) + times.sort(key=lambda t: (t[2])) + cols = '%0.3f %7.3f %7.3f %s' + print '\n%-7s %-7s %-7s %s' % ('user', 'sys', 'real', 'Test') + for user, sys, real, test in times: + print cols % (user, sys, real, test) def outputcoverage(options): @@ -990,15 +990,16 @@ env = createenv(options, testtmp, threadtmp, port) createhgrc(env['HGRCPATH'], options) - starttime = time.time() + starttime = os.times() try: ret, out = runner(testpath, testtmp, options, replacements, env) except KeyboardInterrupt: endtime = time.time() log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime)) raise - endtime = time.time() - times.append((test, endtime - starttime)) + endtime = os.times() + times.append((endtime[0] - starttime[0], endtime[1] - starttime[1], + endtime[4] - starttime[4], test)) vlog("# Ret was:", ret) killdaemons(env['DAEMON_PIDS'])