aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/gencompile.py
blob: 789bd4fabb72d4c002286e05c9edc98d05a25724 (plain)
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
#!/usr/bin/python3.6

import numpy as np              # type: ignore
import matplotlib.pyplot as plt # type: ignore
import sys
from typing import *

##
# Reading data
##

if len(sys.argv) != 4:
  raise Exception("Three arguments are expected: the verifier times, the oracle times, and the output PDF")
_, verifier_file, oracle_file, output_file = sys.argv

def get_coords(filename: str) -> List[Tuple[int, float]]:
  coords = []
  with open(filename, "r") as f:
    for line in f:
      nb_inst_s, time_s = line.split(":")
      coords.append((int(nb_inst_s), float(time_s)))
  return coords

verifier_coords = get_coords(verifier_file)
oracle_coords = get_coords(oracle_file)

##
# Generating PDF
##

fig, ax = plt.subplots()

def do_plot(coords: List[Tuple[int, float]], style: str, label: str):
  x = [coord[0] for coord in coords]
  y = [coord[1] for coord in coords]
  plt.plot(x, y, style, label=label)

plt.xscale("log")
plt.yscale("log")
do_plot(verifier_coords, "b+", "Verifier")
do_plot(oracle_coords, "g+", "Oracle")

ax.set_ylabel("Time x1000 (s)")
ax.set_title("Compilation time")
ax.set_xlabel("Size of basic blocks")
ax.legend()

plt.savefig(output_file)