| 856 | |
| 857 | |
| 858 | def timeReportSlow(resultPath: str) -> str: |
| 859 | title = 'Time report (slowest)' |
| 860 | html = '<!DOCTYPE html>\n' |
| 861 | html += '<html><head><title>{}</title></head><body>\n'.format(title) |
| 862 | html += '<h1>{}</h1>\n'.format(title) |
| 863 | html += '<pre>\n' |
| 864 | html += '<b>' |
| 865 | html += fmt('Package', 'Date Time', OLD_VERSION, 'Head', link=False) |
| 866 | html += '</b>\n' |
| 867 | |
| 868 | current_year = datetime.date.today().year |
| 869 | |
| 870 | data = {} |
| 871 | |
| 872 | for filename in glob.glob(resultPath + '/*'): |
| 873 | if not os.path.isfile(filename) or filename.endswith('.diff'): |
| 874 | continue |
| 875 | datestr = None |
| 876 | for line in open(filename, 'rt'): |
| 877 | line = line.strip() |
| 878 | if line.startswith('cppcheck: '): |
| 879 | if OLD_VERSION not in line: |
| 880 | # Package results seem to be too old, skip |
| 881 | break |
| 882 | # Current package, parse on |
| 883 | continue |
| 884 | if datestr is None and line.startswith(str(current_year) + '-') or line.startswith(str(current_year - 1) + '-'): |
| 885 | datestr = line |
| 886 | continue |
| 887 | if line.startswith('count:'): |
| 888 | count_head = line.split()[1] |
| 889 | if count_head == 'TO!': |
| 890 | # ignore results with timeouts |
| 891 | break |
| 892 | continue |
| 893 | if not line.startswith('elapsed-time:'): |
| 894 | continue |
| 895 | split_line = line.split() |
| 896 | time_base = float(split_line[2]) |
| 897 | time_head = float(split_line[1]) |
| 898 | if time_base < 0.0 or time_head < 0.0: |
| 899 | # ignore results with crashes / errors |
| 900 | break |
| 901 | pkg_name = filename[len(resultPath)+1:] |
| 902 | data[pkg_name] = (datestr, split_line[2], split_line[1], time_head) |
| 903 | break |
| 904 | |
| 905 | sorted_data = sorted(data.items(), key=lambda kv: kv[1][3]) |
| 906 | if len(data) > 100: |
| 907 | first_key, _ = sorted_data[0] |
| 908 | # remove the entry with the lowest run-time |
| 909 | del data[first_key] |
| 910 | |
| 911 | sorted_data = sorted(data.items(), key=lambda kv: kv[1][3], reverse=True) |
| 912 | sorted_dict = collections.OrderedDict(sorted_data) |
| 913 | for key in sorted_dict: |
| 914 | html += fmt(key, sorted_dict[key][0], sorted_dict[key][1], sorted_dict[key][2]) + '\n' |
| 915 | html += '</pre>\n' |