Skip to content

Commit

Permalink
better table and test can now check correctedness
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielegenovese committed Feb 7, 2025
1 parent 1bec7ce commit 3d68b7c
Show file tree
Hide file tree
Showing 43 changed files with 110 additions and 51 deletions.
80 changes: 40 additions & 40 deletions assets/table.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
Example & #Lines & #GV Nodes & #GV Edges & #Warnings & #Errors & Runtime \\
Example & Lines & GV Nodes & GV Edges & Warnings & Errors & Runtime \\
\hline
account & 23 & 19 & 27 & 0 & 2 & 0.261s \\
dining & 31 & 29 & 44 & 0 & 2 & 0.250s \\
hello & 24 & 3 & 3 & 2 & 0 & 0.189s \\
async & 20 & 6 & 6 & 0 & 0 & 0.188s \\
ticktackstop & 46 & 12 & 19 & 7 & 0 & 0.210s \\
ticktackloop & 32 & 5 & 5 & 2 & 0 & 0.184s \\
customer & 54 & 12 & 16 & 1 & 0 & 0.209s \\
serverclient & 41 & 7 & 8 & 8 & 3 & 0.193s \\
trick & 24 & 8 & 8 & 0 & 0 & 0.185s \\
airline & 23 & 12 & 20 & 1 & 0 & 0.225s \\
conditional-case & 26 & 10 & 15 & 1 & 16 & 0.198s \\
for-loop-recursion & 18 & 8 & 9 & 0 & 0 & 0.186s \\
function-call & 17 & 3 & 3 & 1 & 2 & 0.184s \\
high-order-fun & 21 & 10 & 14 & 0 & 3 & 0.193s \\
if-cases & 57 & 86 & 134 & 185 & 30 & 0.543s \\
pass & 16 & 3 & 2 & 0 & 0 & 0.196s \\
producer & 30 & 8 & 7 & 0 & 1 & 0.198s \\
spawn & 22 & 9 & 8 & 0 & 0 & 0.182s \\
unknown & 13 & 1 & 1 & 0 & 0 & 0.187s \\
foo1 & 18 & 6 & 7 & 0 & 0 & 0.215s \\
foo2 & 23 & 4 & 3 & 1 & 1 & 0.190s \\
foo3 & 22 & 10 & 14 & 0 & 0 & 0.195s \\
foo4 & 20 & 12 & 15 & 0 & 2 & 0.194s \\
foo5 & 18 & 39 & 87 & 1 & 0 & 0.317s \\
foo6 & 24 & 6 & 7 & 15 & 2 & 0.200s \\
foo7 & 41 & 43 & 121 & 0 & 6 & 0.520s \\
foo8 & 29 & 27 & 95 & 0 & 171 & 2.893s \\
foo9 & 14 & 2 & 3 & 1 & 3 & 0.191s \\
foo9b & 21 & 4 & 4 & 14 & 1 & 0.188s \\
foo9c & 15 & 6 & 11 & 0 & 0 & 0.198s \\
foo9d & 16 & 3 & 2 & 0 & 0 & 0.186s \\
foo9e & 24 & 9 & 13 & 0 & 5 & 0.193s \\
foo9f & 25 & 4 & 6 & 0 & 4 & 0.193s \\
foo9g & 25 & 21 & 49 & 0 & 7 & 0.231s \\
foo9h & 23 & 12 & 26 & 0 & 5 & 0.196s \\
ping & 36 & 6 & 5 & 1 & 0 & 0.183s \\
airline & 33 & 18 & 34 & 1 & 0 & 0.225s \\
meViolation & 40 & 38 & 54 & 2 & 4 & 0.255s \\
purchase & 47 & 25 & 44 & 6 & 0 & 0.254s \\
account & 23 & 19 & 27 & 0 & 2 & 0.222s \\
dining & 31 & 29 & 44 & 0 & 2 & 0.241s \\
hello & 24 & 3 & 3 & 2 & 0 & 0.220s \\
async & 20 & 6 & 6 & 0 & 0 & 0.211s \\
ticktackstop & 46 & 12 & 19 & 7 & 0 & 0.245s \\
ticktackloop & 32 & 5 & 5 & 2 & 0 & 0.204s \\
customer & 54 & 12 & 16 & 1 & 0 & 0.219s \\
serverclient & 41 & 7 & 8 & 8 & 3 & 0.208s \\
trick & 24 & 8 & 8 & 0 & 0 & 0.197s \\
airline & 23 & 12 & 20 & 1 & 0 & 0.247s \\
conditional-case & 26 & 10 & 15 & 1 & 16 & 0.213s \\
for-loop-recursion & 18 & 8 & 9 & 0 & 0 & 0.187s \\
function-call & 17 & 3 & 3 & 1 & 2 & 0.192s \\
high-order-fun & 21 & 10 & 14 & 0 & 3 & 0.208s \\
if-cases & 57 & 86 & 134 & 185 & 30 & 0.607s \\
pass & 16 & 3 & 2 & 0 & 0 & 0.194s \\
producer & 30 & 8 & 7 & 0 & 1 & 0.210s \\
spawn & 22 & 9 & 8 & 0 & 0 & 0.218s \\
unknown & 13 & 1 & 1 & 0 & 0 & 0.197s \\
foo1 & 18 & 6 & 7 & 0 & 0 & 0.199s \\
foo2 & 23 & 4 & 3 & 1 & 1 & 0.210s \\
foo3 & 22 & 10 & 14 & 0 & 0 & 0.320s \\
foo4 & 20 & 12 & 15 & 0 & 2 & 0.241s \\
foo5 & 18 & 39 & 87 & 1 & 0 & 0.344s \\
foo6 & 24 & 6 & 7 & 15 & 2 & 0.197s \\
foo7 & 41 & 43 & 121 & 0 & 6 & 0.550s \\
foo8 & 29 & 27 & 95 & 0 & 171 & 2.999s \\
foo9 & 14 & 2 & 3 & 1 & 3 & 0.206s \\
foo9b & 21 & 4 & 4 & 14 & 1 & 0.200s \\
foo9c & 15 & 6 & 11 & 0 & 0 & 0.193s \\
foo9d & 16 & 3 & 2 & 0 & 0 & 0.198s \\
foo9e & 24 & 9 & 13 & 0 & 5 & 0.212s \\
foo9f & 25 & 4 & 6 & 0 & 4 & 0.187s \\
foo9g & 25 & 21 & 49 & 0 & 7 & 0.226s \\
foo9h & 23 & 12 & 26 & 0 & 5 & 0.207s \\
ping & 36 & 6 & 5 & 1 & 0 & 0.197s \\
airline & 33 & 18 & 34 & 1 & 0 & 0.247s \\
meViolation & 40 & 38 & 54 & 2 & 4 & 0.317s \\
purchase & 47 & 25 & 44 & 6 & 0 & 0.266s \\
\hline
\end{tabular}
\caption{Global view data}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions examples/unknown/correct_gv.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ digraph global {
n_1 [id="1", shape=circle, label="1"];
n_0 -> n_1 [arrowhead=none];
n_2 [id="2", shape=circle, label="2"];
n_3 [id="3", shape=doublecircle, label="3"];
n_4 [id="2", shape=circle, label="3"];
n_3 [id="3", shape=doublecircle, label="4"];

n_2 -> n_2 [id="[$e|1]", label="main/0.0→main/0.0:unknown"];
n_1 -> n_2 [id="[$e|0]", label="main/0.0→main/0.0:1"];
n_2 -> n_3 [id="[$e|0]", label="main/0.0→main/0.0:0"];
n_2 -> n_4 [id="[$e|1]", label="main/0.0→main/0.0:unknown"];
n_4 -> n_4 [id="[$e|1]", label="main/0.0→main/0.0:unknown"];
n_1 -> n_2 [id="[$e|0]", label="main/0.0→main/0.0:5"];
n_4 -> n_3 [id="[$e|0]", label="main/0.0→main/0.0:0"];
}
File renamed without changes.
3 changes: 2 additions & 1 deletion src/share/share.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ and_rec([{B, L} | T]) ->
format_name(Name) -> string:replace(atol(Name), "/", "_").

format_local_name(Name) -> format_name(Name) ++ "_local_view.dot".
format_global_name(Name) -> format_name(Name) ++ "_global_view.dot".
% format_global_name(Name) -> format_name(Name) ++ "_global_view.dot".
format_global_name(_Name) -> "global_view.dot".

%%% Get a new label for a given graph
new_label(Graph) -> length(digraph:vertices(Graph)) + 1.
Expand Down
68 changes: 62 additions & 6 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,53 @@
import subprocess
import time
import csv
import pydot
import networkx as nx


def load_graph_from_dot(file_path):
graph = pydot.graph_from_dot_file(file_path)[0]
G = nx.DiGraph()

for node in graph.get_nodes():
node_id = node.get_name()
label = node.get_label()
G.add_node(node_id, label=label)

for edge in graph.get_edges():
source = edge.get_source()
destination = edge.get_destination()
label = edge.get_label()
G.add_edge(source, destination, label=label)

return G


def are_graphs_equivalent(G1, G2):
if set(G1.nodes) != set(G2.nodes):
return False

if set(G1.edges) != set(G2.edges):
return False

for node in G1.nodes:
if G1.nodes[node].get("label") != G2.nodes[node].get("label"):
return False

for edge in G1.edges:
if G1[edge[0]][edge[1]].get("label") != G2[edge[0]][edge[1]].get("label"):
return False

return True


def check_correctedness(file1, file2):
G1 = load_graph_from_dot(file1)
try:
G2 = load_graph_from_dot(file2)
return str(are_graphs_equivalent(G1, G2))
except Exception as e:
return "Not present"


def read_csv_file(filepath):
Expand All @@ -26,7 +73,11 @@ def generate_latex_table(columns, rows, caption):
for row in rows:
# print(row)
table += " & ".join(row) + " \\\\ \n"
table += "\\hline\n\\end{tabular}\n\\caption{" + caption + "}\n\\label{tab:gvbench}\n\\end{table}"
table += (
"\\hline\n\\end{tabular}\n\\caption{"
+ caption
+ "}\n\\label{tab:gvbench}\n\\end{table}"
)
return table


Expand Down Expand Up @@ -84,6 +135,8 @@ def generate_latex_table(columns, rows, caption):
for item in test_list:
item = ["./_build/default/bin/chorer"] + item[:-1] # remove minimize of global view
csvfile = item[3] + "/output.csv"
gvfile = item[3] + "/global_view.dot"
correct_gvfile = item[3] + "/correct_gv.dot"
csvs.append(csvfile)
print("Executing ", " ".join(item))
# get time
Expand All @@ -97,6 +150,7 @@ def generate_latex_table(columns, rows, caption):
"warns": str(warns),
"errs": str(errs),
"runtime": "{:.3f}s".format(runtime),
"correct": check_correctedness(gvfile, correct_gvfile),
}
# print(f"{output}\ntime {runtime}\nwarns {warns}\nerrs {errs}")
# time.sleep(1)
Expand All @@ -114,12 +168,13 @@ def generate_latex_table(columns, rows, caption):
# generate global view table
columns = [
"Example",
"#Lines",
"#GV Nodes",
"#GV Edges",
"#Warnings",
"#Errors",
"Lines",
"GV Nodes",
"GV Edges",
"Warnings",
"Errors",
"Runtime",
# "Check",
]
rows = [
[
Expand All @@ -130,6 +185,7 @@ def generate_latex_table(columns, rows, caption):
data["warns"],
data["errs"],
data["runtime"],
# data["correct"],
]
for (file, data) in datas
]
Expand Down

0 comments on commit 3d68b7c

Please sign in to comment.