-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathall_exp_table_builder.py
More file actions
92 lines (66 loc) · 2.46 KB
/
all_exp_table_builder.py
File metadata and controls
92 lines (66 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import argparse
import subprocess
import sys
from pathlib import Path
ROUND = 2
START = r"""
\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[11pt,letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{filecontents}
\usepackage{mathtools}
\usepackage{subfigure}
\usepackage{float}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{algorithm}
\usepackage{listings}
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\usepackage{url}
\usepackage{colortbl}
\usepackage{pdfpages}
\title{Redis Trees}
\begin{document}
\maketitle
Each cell is \textbf{total thoughput}. Each benchmark was launched for $20$ seconds.
~\\
SABT and SABPT has $B = 16$.
"""
END = "\\end{document}\n"
def format_main_ops(ops):
sops = f"%.{ROUND}g" % ops
pos = sops.find("e+0")
if pos == -1:
raise RuntimeError("can not find e+0 in " + sops)
return sops[:pos] + " \cdot {10}^{" + sops[pos+3:pos+4] + "}"
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-etb", "--exp-table-builder", required=True, help="exp_table_builder.py frozen args")
parser.add_argument("-k", "--key", type=int, nargs="+", required=True)
parser.add_argument("-ops", "--operations", type=str, nargs="+", required=True)
parser.add_argument("-o", "--output", type=Path, default="all_exp_table_builder.txt")
args = parser.parse_args()
with open(args.output, 'w') as f:
f.write(START)
for key in args.key:
f.write("\section{key set size = $" + format_main_ops(key) + "$}")
f.write("\n\n")
for ops in args.operations:
ip, dp, rp = list(map(float, ops.split("_")))
fp = 1 - (ip + dp + rp)
f.write("\subsection{" f"ins={ip} del={dp} rq={rp} count={fp}" + "}")
f.write("\n\n")
run_command = f"python3 exp_table_builder.py {args.exp_table_builder} -k {key} -ops {ops}"
try:
cp = subprocess.run(run_command.split(), check=True, capture_output=True, text=True)
f.write(cp.stdout)
f.write("\n")
except subprocess.CalledProcessError as exc:
print("lol")
print(exc)
sys.exit(1)
f.write(END)