#!/usr/bin/python3 import collections import csv import os import sys doc_template = """ {header}

{header}

{test_part} """ table_template = """

{caption}

{header} {rows}
""" def tr(x): return '' + str(x) + '' def td(x): return '' + str(x) + '' def th(x): return '' + str(x) + '' def table_row(r): return tr(''.join([td(f) for f in r])) def table_header(r): return tr(''.join([th(f) for f in r])) def tsv_rows(n): result = '' with open(n) as fd: for row in csv.reader(fd, delimiter="\t", quotechar='"'): result += table_row(row) return result params = collections.defaultdict(str) params['header'] = "ClickHouse Performance Comparison" params['test_part'] = (table_template.format_map( collections.defaultdict(str, caption = 'Changes in performance', header = table_header(['Old, s', 'New, s', 'Relative difference (new - old)/old', 'Randomization distribution quantiles [5%, 50%, 95%]', 'Query']), rows = tsv_rows('changed-perf.tsv'))) + table_template.format( caption = 'Slow on client', header = table_header(['Client time, s', 'Server time, s', 'Ratio', 'Query']), rows = tsv_rows('slow-on-client.tsv')) + table_template.format( caption = 'Unstable', header = table_header(['Old, s', 'New, s', 'Relative difference (new - old)/old', 'Randomization distribution quantiles [5%, 50%, 95%]', 'Query']), rows = tsv_rows('unstable.tsv')) + table_template.format( caption = 'Run errors', header = table_header(['A', 'B']), rows = tsv_rows('run-errors.log')) ) print(doc_template.format_map(params))