# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1252016104 25200
# Node ID fbedb0f125546bf16bc7a4b915a25e4042be0ac7
# Parent db3af9cb2c9affb0a32a8ea3a2c23648c5efe91e
Add timestamps to main.py to calculate run time of tests
These changes allow the user to specify the --print-exec-time flag, which will
print the execution time of each test. If this flag isn't specified, the
total run time of the test is still printed.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r db3af9cb2c9a -r fbedb0f12554 suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py Thu Sep 03 13:03:52 2009 -0700
+++ b/suites/libvirt-cim/main.py Thu Sep 03 15:15:04 2009 -0700
@@ -22,6 +22,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+from time import time
from optparse import OptionParser
import os
import sys
@@ -64,6 +65,9 @@
help="Duplicate the output to stderr")
parser.add_option("--report", dest="report",
help="Send report using mail info: --report=<recipient
addr>")
+parser.add_option("--print-exec-time", action="store_true",
+ dest="print_exec_time",
+ help="Print execution time of each test")
TEST_SUITE = 'cimtest'
CIMTEST_RCFILE = '%s/.cimtestrc' % os.environ['HOME']
@@ -146,6 +150,27 @@
return PASS
+def print_exec_time(testsuite, exec_time):
+
+ #Convert run time from seconds to hours
+ tmp = exec_time / (60 * 60)
+ h = int(tmp)
+
+ #Subtract out hours and convert remainder to minutes
+ tmp = (tmp - h) * 60
+ m = int(tmp)
+
+ #Subtract out minutes and convert remainder to seconds
+ tmp = (tmp - m) * 60
+ s = int(tmp)
+
+ #Subtract out seconds and convert remainder to milliseconds
+ tmp = (tmp - s) * 1000
+ msec = int(tmp)
+
+ testsuite.debug(" Execution time: %sh %smin %ssec %smsec" %
+ (h, m, s, msec))
+
def main():
(options, args) = parser.parse_args()
to_addr = None
@@ -213,6 +238,8 @@
print "\nTesting " + options.virt + " hypervisor"
+ test_run_time_total = 0
+
for test in test_list:
testsuite.debug(div)
t_path = os.path.join(TEST_SUITE, test['group'])
@@ -222,13 +249,25 @@
options.virt, dbg,
options.t_url)
cmd = cdto + ' && ' + ' ' + run
+ start_time = time()
status, output = commands.getstatusoutput(cmd)
+ end_time = time()
os_status = os.WEXITSTATUS(status)
testsuite.print_results(test['group'], test['test'], os_status,
output)
+ exec_time = end_time - start_time
+ test_run_time_total = test_run_time_total + exec_time
+
+ if options.print_exec_time:
+ print_exec_time(testsuite, exec_time)
+
testsuite.debug("%s\n" % div)
+ testsuite.debug("Total test execution: ")
+ print_exec_time(testsuite, test_run_time_total)
+ testsuite.debug("\n")
+
testsuite.finish()
status = cleanup_env(options.ip, options.virt)
Show replies by date
Kaitlin Rupert wrote:
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1252016104 25200
# Node ID fbedb0f125546bf16bc7a4b915a25e4042be0ac7
# Parent db3af9cb2c9affb0a32a8ea3a2c23648c5efe91e
Add timestamps to main.py to calculate run time of tests
These changes allow the user to specify the --print-exec-time flag, which will
print the execution time of each test. If this flag isn't specified, the
total run time of the test is still printed.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r db3af9cb2c9a -r fbedb0f12554 suites/libvirt-cim/main.py
This should have been sent with [TEST] in the subject. Resending this
patch.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com