Loading Benchmark/generate_docs.py +33 −14 Original line number Diff line number Diff line Loading @@ -6,12 +6,34 @@ import matplotlib.pyplot as plt import os import shutil # Names of operations OP_REFINEMENT = "refinement" OP_SEARCH = "search" OP_SEARCH_ALL = "search_all" OP_SEARCH_NOT_REFINED = "search_not_refined" OP_SEARCH_ALL_NOT_REFINED = "search_all_not_refined" def group_by_size(df: pd.DataFrame) -> pd.DataFrame: # Group by size, ale calculate mean, min, max for each group # And add # LINEAR_MEAN, LINEAR_MIN, LINEAR_MAX # CLASSIC_MEAN, CLASSIC_MIN, CLASSIC_MAX # SPEEDUP_MEAN, SPEEDUP_MIN, SPEEDUP_MAX df = df.groupby("SIZE").agg( { "LINEAR": ["mean", "min", "max"], "CLASSIC": ["mean", "min", "max"], "SPEEDUP": ["mean", "min", "max"], } ) df.columns = [ "LINEAR_AVG", "LINEAR_MIN", "LINEAR_MAX", "CLASSIC_AVG", "CLASSIC_MIN", "CLASSIC_MAX", "SPEEDUP_AVG", "SPEEDUP_MIN", "SPEEDUP_MAX", ] df = df.reset_index() # print(df) return df if len(sys.argv) != 3: Loading Loading @@ -65,15 +87,12 @@ for distribution in distributions: # Create dataframes all_df = filtered[["SIZE", "LINEAR", "CLASSIC", "SPEEDUP"]] times_df = filtered[["SIZE", "LINEAR", "CLASSIC"]] speedup_df = filtered[["SIZE", "SPEEDUP"]] # Sort by size times_df = times_df.sort_values(by=["SIZE"]) speedup_df = speedup_df.sort_values(by=["SIZE"]) all_df = group_by_size(all_df) all_df.sort_values(by=["SIZE"], inplace=True) # Create plots, save as pdf # Times times_df.plot(x="SIZE", y=["LINEAR", "CLASSIC"], marker="o") all_df.plot(x="SIZE", y=["LINEAR_AVG", "CLASSIC_AVG"], marker="o") plt.xlabel("Size") plt.ylabel("Time (s)") plt.title(title) Loading @@ -82,10 +101,10 @@ for distribution in distributions: plt.close() # Speedup, show 2 lines: speedup and 1 speedup_df.plot(x="SIZE", y=["SPEEDUP"], marker="o") all_df.plot(x="SIZE", y=["SPEEDUP_AVG"], marker="o") # Add line y=1 plt.plot( [speedup_df["SIZE"].min(), speedup_df["SIZE"].max()], [all_df["SIZE"].min(), all_df["SIZE"].max()], [1, 1], color="red", linestyle="dashed", Loading Benchmark/run_benchmarks.sh +12 −9 Original line number Diff line number Diff line #!/bin/bash DESIRED_DISTRIBUTIONS=("unif" "normal" "exp") DESIRED_REFINES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000) DESIRED_SEARCHES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000 20000000 50000000 100000000) DESIRED_REFINES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000) DESIRED_SEARCHES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000) TMP_DIR="bench" INSTANCES=5 # Stop on error set -e Loading @@ -24,13 +25,15 @@ run_benchmark() { local refine="$2" local search="$3" for i in $(seq 1 $INSTANCES); do # Check if bench dir exists, remove if it does if [ -d "bench" ]; then rm -rf bench if [ -d $TMP_DIR ]; then rm -rf $TMP_DIR fi ./$GENERATOR $refine $search $distribution $TMP_DIR ./$BIN $TMP_DIR >> $RESULT_FILE done } echo "OPERATION;REFINES;SIZE;DISTRIBUTION;LINEAR;CLASSIC;SPEEDUP" > $RESULT_FILE Loading Loading
Benchmark/generate_docs.py +33 −14 Original line number Diff line number Diff line Loading @@ -6,12 +6,34 @@ import matplotlib.pyplot as plt import os import shutil # Names of operations OP_REFINEMENT = "refinement" OP_SEARCH = "search" OP_SEARCH_ALL = "search_all" OP_SEARCH_NOT_REFINED = "search_not_refined" OP_SEARCH_ALL_NOT_REFINED = "search_all_not_refined" def group_by_size(df: pd.DataFrame) -> pd.DataFrame: # Group by size, ale calculate mean, min, max for each group # And add # LINEAR_MEAN, LINEAR_MIN, LINEAR_MAX # CLASSIC_MEAN, CLASSIC_MIN, CLASSIC_MAX # SPEEDUP_MEAN, SPEEDUP_MIN, SPEEDUP_MAX df = df.groupby("SIZE").agg( { "LINEAR": ["mean", "min", "max"], "CLASSIC": ["mean", "min", "max"], "SPEEDUP": ["mean", "min", "max"], } ) df.columns = [ "LINEAR_AVG", "LINEAR_MIN", "LINEAR_MAX", "CLASSIC_AVG", "CLASSIC_MIN", "CLASSIC_MAX", "SPEEDUP_AVG", "SPEEDUP_MIN", "SPEEDUP_MAX", ] df = df.reset_index() # print(df) return df if len(sys.argv) != 3: Loading Loading @@ -65,15 +87,12 @@ for distribution in distributions: # Create dataframes all_df = filtered[["SIZE", "LINEAR", "CLASSIC", "SPEEDUP"]] times_df = filtered[["SIZE", "LINEAR", "CLASSIC"]] speedup_df = filtered[["SIZE", "SPEEDUP"]] # Sort by size times_df = times_df.sort_values(by=["SIZE"]) speedup_df = speedup_df.sort_values(by=["SIZE"]) all_df = group_by_size(all_df) all_df.sort_values(by=["SIZE"], inplace=True) # Create plots, save as pdf # Times times_df.plot(x="SIZE", y=["LINEAR", "CLASSIC"], marker="o") all_df.plot(x="SIZE", y=["LINEAR_AVG", "CLASSIC_AVG"], marker="o") plt.xlabel("Size") plt.ylabel("Time (s)") plt.title(title) Loading @@ -82,10 +101,10 @@ for distribution in distributions: plt.close() # Speedup, show 2 lines: speedup and 1 speedup_df.plot(x="SIZE", y=["SPEEDUP"], marker="o") all_df.plot(x="SIZE", y=["SPEEDUP_AVG"], marker="o") # Add line y=1 plt.plot( [speedup_df["SIZE"].min(), speedup_df["SIZE"].max()], [all_df["SIZE"].min(), all_df["SIZE"].max()], [1, 1], color="red", linestyle="dashed", Loading
Benchmark/run_benchmarks.sh +12 −9 Original line number Diff line number Diff line #!/bin/bash DESIRED_DISTRIBUTIONS=("unif" "normal" "exp") DESIRED_REFINES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000) DESIRED_SEARCHES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000 20000000 50000000 100000000) DESIRED_REFINES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000) DESIRED_SEARCHES=(10000 20000 50000 100000 200000 500000 1000000 2000000 5000000 10000000) TMP_DIR="bench" INSTANCES=5 # Stop on error set -e Loading @@ -24,13 +25,15 @@ run_benchmark() { local refine="$2" local search="$3" for i in $(seq 1 $INSTANCES); do # Check if bench dir exists, remove if it does if [ -d "bench" ]; then rm -rf bench if [ -d $TMP_DIR ]; then rm -rf $TMP_DIR fi ./$GENERATOR $refine $search $distribution $TMP_DIR ./$BIN $TMP_DIR >> $RESULT_FILE done } echo "OPERATION;REFINES;SIZE;DISTRIBUTION;LINEAR;CLASSIC;SPEEDUP" > $RESULT_FILE Loading