diff --git a/modules/ts/misc/perf_tests_timing.py b/modules/ts/misc/perf_tests_timing.py index d3e2c571e7..70d2aa2f03 100644 --- a/modules/ts/misc/perf_tests_timing.py +++ b/modules/ts/misc/perf_tests_timing.py @@ -7,28 +7,24 @@ from operator import itemgetter, attrgetter from summary import getSetName, alphanum_keyselector if __name__ == "__main__": - usage = "%prog .xml" + usage = "%prog .xml [...]" parser = OptionParser(usage = usage) - for arg in sys.argv: - print arg - - parser.add_option("-o", "--output", dest="format", - help="output results in text format (can be 'txt', 'html' or 'auto' - default)", - metavar="FMT", default="auto") + parser.add_option("-o", "--output", dest = "format", + help = "output results in text format (can be 'txt', 'html' or 'auto' - default)", + metavar = 'FMT', default = 'auto') (options, args) = parser.parse_args() - - options.generateHtml = detectHtmlOutputType(options.format) - if 1 != len(args): parser.print_help() exit(0) + options.generateHtml = detectHtmlOutputType(options.format) + # expand wildcards and filter duplicates file = os.path.abspath(args[0]) if not os.path.isfile(file): - print 'Incorrect file name!' + sys.stderr.write("IOError reading \"" + file + "\" - " + str(err) + os.linesep) parser.print_help() exit(0) @@ -71,7 +67,8 @@ if __name__ == "__main__": groupName = next(c for c in cases if c).shortName() if groupName != prevGroupName: if prevGroupName != None: - testsuits.append((prevGroupName, suit_time, has_failed)) + testsuits.append({'name': prevGroupName, 'time': suit_time, \ + 'failed': has_failed}) has_failed = False suit_time = 0 prevGroupName = groupName @@ -79,29 +76,30 @@ if __name__ == "__main__": for i in range(setsCount): case = cases[i] if not case is None: - if case.get("status") == "run": - suit_time += case.get("time") - if case.get("status") == "failed": + if case.get('status') == 'run': + suit_time += case.get('time') + if case.get('status') == 'failed': has_failed = True tbl = table() # header - tbl.newColumn("name", "Name", align = "left", cssclass = "col_name") - tbl.newColumn("time", "Time (ms)", align = "left", cssclass = "col_name") - tbl.newColumn("failed", "Failed tests", align = "center", cssclass = "col_name") + tbl.newColumn('name', 'Name of testsuit', align = 'left', cssclass = 'col_name') + tbl.newColumn('time', 'Time (ms)', align = 'left', cssclass = 'col_name') + tbl.newColumn('failed', 'Failed tests', align = 'center', cssclass = 'col_name') # rows - for suit in sorted(testsuits, key=lambda suit: suit[1], reverse=True): + for suit in sorted(testsuits, key = lambda suit: suit['time'], reverse = True): tbl.newRow() - tbl.newCell("name", suit[0]) - tbl.newCell("time", formatValue(suit[1], "", ""), suit[1]) - if (suit[2]): - tbl.newCell("failed", "Yes") + tbl.newCell('name', suit['name']) + tbl.newCell('time', formatValue(suit['time'], '', ''), suit['time']) + if (suit['failed']): + tbl.newCell('failed', 'Yes') + else: + tbl.newCell('failed', ' ') # output table if options.generateHtml: - htmlPrintHeader(sys.stdout, "Timings of %s tests from %s test logs" % (len(test_cases), setsCount)) tbl.htmlPrintTable(sys.stdout) htmlPrintFooter(sys.stdout) else: