From a17257448d25be15cda70b951d8e8a5c1776b0ab Mon Sep 17 00:00:00 2001 From: Martin Peres Date: Fri, 28 Aug 2015 18:44:25 +0300 Subject: stats/gen_report: move to the mako template engine --- stats/gen_report.py | 195 ++++++++++++++++++++++++---------------------------- 1 file changed, 89 insertions(+), 106 deletions(-) (limited to 'stats') diff --git a/stats/gen_report.py b/stats/gen_report.py index 6ebe351..82d8c86 100755 --- a/stats/gen_report.py +++ b/stats/gen_report.py @@ -4,6 +4,7 @@ from matplotlib.patches import Rectangle import matplotlib.gridspec as gridspec import matplotlib.pyplot as plt from scipy.stats import gaussian_kde +from mako.template import Template import argparse import sys import os @@ -175,78 +176,97 @@ html_template=""" - Performance report on the run named '{run_name}' + Performance report on the run named '${run_name}' + <%def name="makeTableheader(benchmarks)"> + + Commit + Geometric mean + % for benchmark in benchmarks: + ${benchmark.full_name} + % endfor + + + + <%def name="makeCommitRow(commit, benchmarks)"> + + ${commit.label} + ${commit.geom} (${commit.geom_diff} %) + % for benchmark in benchmarks: + <% + result = None + for res in commit.results: + if res.benchmark == benchmark: + result = res + sparkline_img = report_folder + result.data_raw_file + ".spark.svg" + break + %> + % if result.value != None: + + + ${result.value} (${result.diff} %) + Test's time series and density of probability + + + % else: +
NO DATA
+ % endif + % endfor + + + -

Performance report on the run named '{run_name}'

+

Performance report on the run named '${run_name}'

Trends

-
Trends
+
Trends

Stats

- - - - - {tbl_hdr_benchmarks} - - {tbl_entries} + ${makeTableheader(benchmarks)} + % for commit in commits: + ${makeCommitRow(commit, benchmarks)} + % endfor
Commit #Commit SHA1Geometric mean

Commits

- {commits} + % for commit in commits: +

${commit.label} - ${commit.full_name}

+

Patch Compilation logs

+ + ${makeTableheader(benchmarks)} + ${makeCommitRow(commit, benchmarks)} +
+ + % for benchmark in benchmarks: + <% + result = None + for res in commit.results: + if res.benchmark == benchmark: + result = res + sparkline_img = report_folder + result.data_raw_file + ".spark.svg" + break + %> + % if result.value != None: +

${benchmark.full_name} (commit ${commit.full_name})

+ +

Original data

+ + Test's time series and density of probability + % endif + % endfor + % endfor """ -table_commit_template=""" - - {commitNum} - {sha1} - {geom_mean:.2f} ({geom_diff:+.2f} %) - {tbl_res_benchmarks} - -""" - -table_entry_template=""" - - - {value:.2f} ({diff:+.2f} %) - Test's time series and density of probability - -""" - -table_entry_no_results_template="""
NO DATA
""" - -commit_template=""" -

{commit}

-

Patch Compilation logs

- - - - - - {tbl_hdr_benchmarks} - - {commit_results} -
Commit #Commit SHA1Geometric mean
- {benchs}""" - -bench_template=""" -

{bench_name} (commit {commit})

- -

Original data

- - Test's time series and density of probability""" - def computeDiffAndColor(prev, new): if prev > 0: if args.frametime: @@ -256,6 +276,8 @@ def computeDiffAndColor(prev, new): else: diff = 0 + diff = float("{0:.2f}".format(diff)) + if diff < -1.5 or diff == float('inf'): color = "#FF0000" elif diff > 1.5: @@ -269,16 +291,7 @@ def computeDiffAndColor(prev, new): # Create the html file print("Generating the HTML") -# generate the table's header -tbl_hdr_benchmarks = "" -for benchmark in report.benchmarks: - tbl_hdr_benchmarks += "{benchmark}\n".format(benchmark=benchmark.full_name) - -# generate the reports for each commits -commits_txt = "" -tbl_entries_txt = "" geom_prev = -1 -i = 0 for commit in report.commits: benchs_txt = "" tbl_res_benchmarks = "" @@ -290,52 +303,22 @@ for commit in report.commits: break if result != None: - value = array(result.data).mean() - diff, color = computeDiffAndColor(result.benchmark.prevValue, value) - result.benchmark.prevValue = value - - img_src_name = genFileNameReportImg(report_folder, result.data_raw_file) - sparkline_img = genFileNameSparkline(report_folder, result.data_raw_file) - - # Generate the html - benchs_txt += bench_template.format(sha1=commit.sha1, - commit=commit.full_name, - bench_name=result.benchmark.full_name, - img_src=img_src_name, - raw_data_file=result.data_raw_file) - - tbl_res_benchmarks += table_entry_template.format(sha1=commit.sha1, - bench_name=result.benchmark.full_name, - sparkline_img=sparkline_img, - value=value, - diff=diff, - color=color) - else: - tbl_res_benchmarks += table_entry_no_results_template - - # generate the html - diff, color = computeDiffAndColor(geom_prev, commit.geom_mean()) - geom_prev = commit.geom_mean() - commit_results = table_commit_template.format(commitNum=i, sha1=commit.sha1, - geom_mean=commit.geom_mean(), - geom_diff=diff, geom_color=color, - tbl_res_benchmarks=tbl_res_benchmarks) - tbl_entries_txt += commit_results - commits_txt += commit_template.format(commit=commit.full_name, - sha1=commit.sha1, - benchs=benchs_txt, - compile_log=commit.compile_log, - tbl_hdr_benchmarks=tbl_hdr_benchmarks, - commit_results=commit_results, - patch=commit.patch) - i += 1 - -# Generate the final html file -html = html_template.format(run_name=args.log_folder, - commits=commits_txt, - tbl_entries=tbl_entries_txt, - tbl_hdr_benchmarks=tbl_hdr_benchmarks, - report_folder=report_folder); + result.value = float("{0:.2f}".format(array(result.data).mean())) + result.diff, result.color = computeDiffAndColor(result.benchmark.prevValue, + result.value) + result.benchmark.prevValue = result.value + + result.img_src_name = genFileNameReportImg(report_folder, result.data_raw_file) + result.sparkline_img = genFileNameSparkline(report_folder, result.data_raw_file) + + commit.geom = float("{0:.2f}".format(commit.geom_mean())) + commit.geom_diff, commit.geom_color = computeDiffAndColor(geom_prev, commit.geom) + geom_prev = commit.geom + +html = Template(html_template).render(run_name=args.log_folder, + report_folder=report_folder, + benchmarks=report.benchmarks, + commits=report.commits) with open(html_name, 'w') as f: f.write(html) -- cgit v1.2.3