From 0fc3e699139bb76cb749c21baeabbb185db15406 Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Thu, 14 Nov 2024 19:14:08 +0100 Subject: [PATCH] Use fraction diff --- comparisons/resources-diff.py | 50 +++++++++++++++-------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/comparisons/resources-diff.py b/comparisons/resources-diff.py index bc64432aff0..605c8dab3f3 100755 --- a/comparisons/resources-diff.py +++ b/comparisons/resources-diff.py @@ -11,8 +11,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): dkey = "%s_diff" % metric res[dkey] = dmetric pdmetric = 0.0 - if not data[metric] == 0.0: - pdmetric = 100 * dmetric / data[metric] + pdmetric = 100 * dmetric pdkey = "%s_pdiff" % metric res[pdkey] = pdmetric fkey = "%s_frac" % metric @@ -24,8 +23,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): dfkey = "%s_frac_diff" % metric res[dfkey] = dfmetric pdfmetric = 0.0 - if not fdata == 0.0: - pdfmetric = 100 * dfmetric / fdata + pdfmetric = 100 * dfmetric dkpkey = "%s_frac_pdiff" % metric res[dkpkey] = pdfmetric @@ -57,7 +55,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): for metric in metrics: datacumul[metric] = module[metric] datacumulsib[module["type"]] = datacumul -print(datacumulsib) +# print(datacumulsib) with open(sys.argv[2]) as f: prdata = json.load(f) @@ -80,7 +78,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): for metric in metrics: datacumul[metric] = module[metric] datacumulspr[module["type"]] = datacumul -print(datacumulspr) +# print(datacumulspr) if ibdata["total"]["label"] != prdata["total"]["label"]: print("Warning: input files describe different process names") @@ -132,19 +130,19 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): + "warn threshold %0.2f" % threshold + '%' + "error threshold %0.2f" % error_threshold + + '%' + + "warn threshold -%0.2f" % threshold + + '%' + + "warn threshold -%0.2f" % error_threshold + "%", - "metric:
<pull request >
<baseline>
(PR - baseline)
<100* (PR - baseline)/baseline>
" + "metric:
<pull request >
<baseline>
(PR - baseline)
<100* (PR - baseline)>
" + "" + '' + '' + '' - + '' + '' - + '' - + '' - + '' - + '' - + '' + + '' + + '' + '' + "" + "" % prdata["total"]["type"] @@ -155,37 +153,31 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): ibdata["total"]["time_real"], results["total"]["time_real_diff"], ) - + '' % results["total"]["time_real_pdiff"] + '' % ( prdata["total"]["time_thread"], ibdata["total"]["time_thread"], results["total"]["time_thread_diff"], ) - + '' % results["total"]["time_thread_pdiff"] + '' % ( prdata["total"]["mem_alloc"], ibdata["total"]["mem_alloc"], results["total"]["mem_alloc_diff"], ) - + '' % results["total"]["mem_alloc_pdiff"] + '' % (prdata["total"]["mem_free"], ibdata["total"]["mem_free"], results["total"]["mem_free_diff"]) - + '' % results["total"]["mem_free_pdiff"] + "" % (prdata["total"]["events"], ibdata["total"]["events"], results["total"]["events"]) + "
TypeLabelreal timereal time percent diffcpu timecpu time percent diffallocated memory totalallocated memory percent diffdeallocated memory diffdeallocated memory percent diffallocated memory deallocated memory events
%s%0.2f%%%0.6f
%0.6f
%0.6f
%0.2f%%%0.f
%0.f
%0.f
%0.2f%%%0.f
%0.f
%0.f
%0.2f%%%i
%i
%i
" + '' + '' - + '' - + '' - + '' - + '' + + '' + + '' + + '' + + '' + '' - + '' + '' - + '' + '' + "", ] @@ -198,10 +190,14 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): moduleres = datamapres[key] cellString = '" % moduleres["time_thread_frac_pdiff"] + '' % (moduleib["mem_alloc"], modulepr["mem_alloc"], moduleres["mem_alloc_diff"]) - + '' % moduleres["mem_alloc_pdiff"] + '' - % (moduleib["mem_free"], modulepr["mem_free"], moduleres["mem_free_pdiff"]) - + '' % moduleres["mem_free_diff"] + % (moduleib["mem_free"], modulepr["mem_free"], moduleres["mem_free_diff"]) + "" % (moduleib["events"], modulepr["events"], moduleres["events"]) + ""
Module typeModule labelreal time fraction percentreal time fraction percent diffcpu time fraction percentcpu time fraction percent diffreal time fractionreal time fraction diff percentcpu time fraction cpu time fraction diff percentallocated memory diffallocated memory percent diffdeallocated memory diffdeallocated memory percent diffevents
threshold: + if moduleres["time_thread_frac_pdiff"] > threshold: color = 'bgcolor="orange"' - if abs(moduleres["time_thread_frac_pdiff"]) > error_threshold: + if moduleres["time_thread_frac_pdiff"] > error_threshold: color = 'bgcolor="red"' + if moduleres["time_thread_frac_pdiff"] < -1.0 * threshold: + color = 'bgcolor="cyan"' + if moduleres["time_thread_frac_pdiff"] < -1.0 * error_threshold: + color = 'bgcolor="green"' cellString += color cellString += ">" summaryLines += [ @@ -225,10 +221,8 @@ def diff_from(metrics, data, data_total, dest, dest_total, res): + "%0.6f%%%0.f
%0.f
%0.f
%0.2f%%%0.f
%0.f
%0.f
%0.2f%%%i
%i
%i