Skip to content

Commit

Permalink
Black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gartung committed Nov 5, 2024
1 parent 28e277c commit bb81d17
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions comparisons/resources-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
pdkey = "%s_pdiff" % metric
res[pdkey] = pdmetric
fkey = "%s_frac" % metric
fdest = 100*dest[metric]/dest_total[metric]
fdest = 100 * dest[metric] / dest_total[metric]
dest[fkey] = fdest
fdata = 100*data[metric]/data_total[metric]
fdata = 100 * data[metric] / data_total[metric]
data[fkey] = fdata
dfmetric = fdest - fdata
dfkey = "%s_frac_diff" % metric
Expand All @@ -29,6 +29,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
dkpkey = "%s_frac_pdiff" % metric
res[dkpkey] = pdfmetric


if len(sys.argv) == 1:
print(
"""Usage: resources-diff.py FILE1 FILE2
Expand Down Expand Up @@ -66,7 +67,9 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
results["total"]["type"] = input["total"]["type"]
results["modules"] = []

diff_from(metrics, input["total"], input["total"], output["total"], output["total"], results["total"])
diff_from(
metrics, input["total"], input["total"], output["total"], output["total"], results["total"]
)

for module in input["modules"]:
key = module["type"] + "|" + module["label"]
Expand Down Expand Up @@ -103,7 +106,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
+ "%</td><td></td></tr>",
"<tr><td>metric:<BR>&lt;pull request &gt;<BR>&lt;baseline&gt;<BR>(PR - baseline)</td><td><br>&lt;100* (PR - baseline)/baseline&gt;<br></td></tr></table>"
+ "<table>"
+'<tr><td align="center">Type</td>'
+ '<tr><td align="center">Type</td>'
+ '<td align="center">Label</td>'
+ '<td align="center">real time</td>'
+ '<td align="center">real time percent diff</td>'
Expand All @@ -118,18 +121,31 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
+ "<td>%s</td>" % input["total"]["type"]
+ "<td>%s</td>" % input["total"]["label"]
+ '<td align="right">%0.6f<br>%0.6f<br>%0.6f</td>'
% (input["total"]["time_real"], output["total"]["time_real"], results["total"]["time_real_diff"])
% (
input["total"]["time_real"],
output["total"]["time_real"],
results["total"]["time_real_diff"],
)
+ '<td align="right">%0.2f%%</td>' % results["total"]["time_real_pdiff"]
+ '<td align="right">%0.6f<br>%0.6f<br>%0.6f</td>'
% (input["total"]["time_thread"], output["total"]["time_thread"], results["total"]["time_thread_diff"])
% (
input["total"]["time_thread"],
output["total"]["time_thread"],
results["total"]["time_thread_diff"],
)
+ '<td align="right">%0.2f%%</td>' % results["total"]["time_thread_pdiff"]
+ '<td align="right">%0.f<br>%0.f<br>%0.f</td>'
% (input["total"]["mem_alloc"], output["total"]["mem_alloc"], results["total"]["mem_alloc_diff"])
% (
input["total"]["mem_alloc"],
output["total"]["mem_alloc"],
results["total"]["mem_alloc_diff"],
)
+ '<td align="right">%0.2f%%</td>' % results["total"]["mem_alloc_pdiff"]
+ '<td align="right">%0.f<br>%0.f<br>%0.f</td>'
% (input["total"]["mem_free"], output["total"]["mem_free"], results["total"]["mem_free_diff"])
+ '<td align="right">%0.2f%%</td>' % results["total"]["mem_free_pdiff"]
+ "<td>%i<br>%i<br>%i</td>" % (input["total"]["events"], output["total"]["events"], results["total"]["events"])
+ "<td>%i<br>%i<br>%i</td>"
% (input["total"]["events"], output["total"]["events"], results["total"]["events"])
+ "</tr></table>"
+ '<table><tr><td align="center">Module type</td>'
+ '<td align="center">Module label</td>'
Expand Down Expand Up @@ -164,10 +180,18 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
+ "<td>%s</td>" % module3["type"]
+ "<td>%s</td>" % module3["label"]
+ '<td align="right">%0.6f<br>%0.6f<br>%0.6f</td>'
% (module1["time_real_frac"], module2["time_real_frac"], module3["time_real_frac_diff"])
% (
module1["time_real_frac"],
module2["time_real_frac"],
module3["time_real_frac_diff"],
)
+ '<td align="right">%0.6f%%</td>' % module3["time_real_frac_pdiff"]
+ '<td align="right">%0.6f<br>%0.6f<br>%0.6f</td>'
% (module1["time_thread_frac"], module2["time_thread_frac"], module3["time_thread_frac_diff"])
% (
module1["time_thread_frac"],
module2["time_thread_frac"],
module3["time_thread_frac_diff"],
)
+ cellString
+ "%0.6f%%</td>" % module3["time_thread_frac_pdiff"]
+ '<td align="right">%0.f<br>%0.f<br>%0.f</td>'
Expand All @@ -180,8 +204,7 @@ def diff_from(metrics, data, data_total, dest, dest_total, res):
+ "</tr>"
]

summaryLines += [
]
summaryLines += []
summaryLines += ["</body></html>"]

summaryFile = os.path.dirname(sys.argv[1]) + "/diff-" + os.path.basename(sys.argv[1]) + ".html"
Expand Down

0 comments on commit bb81d17

Please sign in to comment.