Skip to content

Commit

Permalink
clean up test files
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiYang31 committed Apr 15, 2024
1 parent d06f565 commit def9a04
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/experiments/function_calls/tests/test_fcapc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def __init__(self) -> None:
self.fcn_call_apc_computer = fcn_call_path_complexity_naive.FunctionCallPathComplexity(log)
self.converter = CPPConvert(log)

# nfcapc stands for new function call apc, which is the apc computed by fc_path_complexity_final
# pylint: disable=broad-except
def collect(self, path:str) -> None:
"""Compute the metrics for all files and store the data."""
Expand Down Expand Up @@ -49,7 +48,6 @@ def collect(self, path:str) -> None:
if graphs is None:
graphs = self.converter.to_graph(
os.path.splitext(file)[0], ".cpp")
if graphs is None:
print("No Graphs")
continue

Expand Down
37 changes: 24 additions & 13 deletions src/experiments/function_calls/tests/test_getrgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@ def collect(self, path: str) -> None:
files = [line.rstrip() for line in funcs]

for i in files:
# if the line starts with "*", ignore
if i[0:1] == "*":
continue
file = i.split()[0]
funcs = i.split()[1:]
print(f"Now analyzing {file}")
graphs = self.converter.to_graph(os.path.splitext(file)[0], ".c")
print(graphs)
print(f"all graphs in this file {graphs}")

#no graphs in the file
if graphs is None:
graphs = self.converter.to_graph(
os.path.splitext(file)[0], ".cpp")
if graphs is None:
print("No Graphs")
continue

for graph_name, graph in graphs.items():
print('Graph Name: ', graph_name)

Expand Down Expand Up @@ -89,28 +91,37 @@ def collect(self, path: str) -> None:
print(exc)
exception_type = "Timeout" if isinstance(exc, TimeoutError) else "Other"

print(getrgfapc)
new_row = {"file_name": file, "graph_name": graph.name, "getrgfapc": getrgfapc["rfcapc"],
"getrgfapc_time": getrgfruntime, "longest for getrgf": get_max_time(getrgfapc)[0], "longest time":get_max_time(getrgfapc)[1],
"getrgfTime":getrgfapc["getrgfTime"], "firstHalfTime": getrgfapc['firstHalfTime'],
"exception_type": exception_type,'case':getrgfapc['case'],'gamma':getrgfapc['gamma']}
new_row = {"file_name": file,
"graph_name": graph.name,
"getrgfapc": getrgfapc["rfcapc"],
"getrgfapc_time": getrgfruntime,
"longest for getrgf": get_max_time(getrgfapc)[0],
"longest time":get_max_time(getrgfapc)[1],
"getrgfTime":getrgfapc["getrgfTime"],
"firstHalfTime": getrgfapc['firstHalfTime'],
"exception_type": exception_type,
'case':getrgfapc['case'],
'gamma':getrgfapc['gamma']}

data = data._append(new_row, ignore_index=True)
# only keep columns graph_name, rapc, fcapc, num_vertices, edge_count, and runtimes
data = data[["graph_name", "getrgfapc", "getrgfapc_time", 'getrgfTime', 'firstHalfTime', "longest for getrgf", "longest time",'case','gamma']]

# format rapc column decimals to have at most 3 decimal places, e.g. 0.33333333n -> 0.333n
# data['rapc'] = data['rapc'].apply(lambda x: round_tuple_of_exprs(x, 3))
# print(data[['graph_name', "apc",'rapc',"rapc_time","fcapc","fcapc_time"]])
print(data[["graph_name", "getrgfapc", "getrgfapc_time", 'getrgfTime', 'firstHalfTime']])


# create directory if it doesn't exist
if not os.path.exists("/app/code/experiments/function_calls/data"):
os.makedirs("/app/code/experiments/function_calls/data")
data.to_csv("/app/code/experiments/function_calls/data/getrgfapc_data.csv")


# format rapc column decimals to have at most 3 decimal places, e.g. 0.33333333n -> 0.333n
# data['rapc'] = data['rapc'].apply(lambda x: round_tuple_of_exprs(x, 3))
# print(data[['graph_name', "apc",'rapc',"rapc_time","fcapc","fcapc_time"]])
print(data[["graph_name", "getrgfapc", "getrgfapc_time", 'getrgfTime', 'firstHalfTime']])




def round_tuple_of_exprs(tup, num_digits):
return tuple(round_expr(expr, num_digits) for expr in tup)

Expand Down
12 changes: 10 additions & 2 deletions src/experiments/testFiles.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
/app/code/tests/cFiles/SV_benchmark/bitvector/s3_srvr_1.BV.c.cil.c
/app/code/tests/cFiles/C-master/data_structures/array/carray.c
/app/code/tests/cFiles/C-master/sorting/bead_sort.c bead_sort
/app/code/tests/cFiles/C-master/sorting/binary_insertion_sort.c insertionSort
/app/code/tests/cFiles/C-master/sorting/bogo_sort.c bogo_sort
/app/code/tests/cFiles/C-master/sorting/bubble_sort.c bubbleSort
/app/code/tests/cFiles/C-master/sorting/bubble_sort_2.c bubble_sort //does not timeout
/app/code/tests/cFiles/C-master/sorting/bubble_sort_recursion.c bubbleSort
/app/code/tests/cFiles/C-master/sorting/bucket_sort.c BucketSort
/app/code/tests/cFiles/C-master/sorting/cocktail_sort.c cocktailSort
/app/code/tests/cFiles/C-master/sorting/comb_sort.c sort
/app/code/tests/cFiles/C-master/sorting/counting_sort.c main

0 comments on commit def9a04

Please sign in to comment.