-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from LAPKB/net
Net
- Loading branch information
Showing
47 changed files
with
2,122 additions
and
4,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ settings.json | |
/benches/*.json | ||
log.txt | ||
op.csv | ||
*results.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# Check if enough arguments are supplied | ||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: ./time_compare.sh <example_name> <N> <commit-hash-1> <commit-hash-2>" | ||
exit 1 | ||
fi | ||
|
||
# Input arguments | ||
EXAMPLE_NAME=$1 | ||
N=$2 | ||
COMMIT1=$3 | ||
COMMIT2=$4 | ||
|
||
# Check if bc is installed | ||
if ! command -v bc &> /dev/null | ||
then | ||
echo "'bc' is required but it's not installed. Please install it using your package manager." | ||
exit 1 | ||
fi | ||
|
||
# Output file based on example name | ||
OUTPUT_FILE="${EXAMPLE_NAME}_time_comparison_results.txt" | ||
echo "Time comparison results" > $OUTPUT_FILE | ||
echo "Example: $EXAMPLE_NAME" >> $OUTPUT_FILE | ||
echo "===================================" >> $OUTPUT_FILE | ||
|
||
# Function to run the example N times and log the average time | ||
function time_commit() { | ||
COMMIT=$1 | ||
EXAMPLE_NAME=$2 | ||
N=$3 | ||
TOTAL_TIME=0 | ||
|
||
echo "Checking out commit $COMMIT" | ||
git checkout $COMMIT | ||
|
||
# Running the example N times | ||
echo "Running $EXAMPLE_NAME in release mode for $N times" | ||
|
||
# # Makes sure the target directory is clean | ||
# cargo clean -q | ||
|
||
#compile the example | ||
echo "Compilating $COMMIT..." | ||
cargo build --release -q --example $EXAMPLE_NAME | ||
echo "Done compilating $COMMIT..." | ||
for i in $(seq 1 $N); do | ||
|
||
|
||
echo "Run $i: executing 'cargo run' for commit $COMMIT..." | ||
|
||
# Capture both stdout and stderr to handle errors from cargo run | ||
RUN_TIME=$( { /usr/bin/time -f "%e" cargo run --release --example $EXAMPLE_NAME 2>&1 | grep -Eo '^[0-9]+\.[0-9]+$'; } 2>&1 ) | ||
|
||
# Validate that RUN_TIME is a valid float | ||
if [[ $RUN_TIME =~ ^[0-9]+(\.[0-9]+)?$ ]]; then | ||
echo "Run $i: ${RUN_TIME}s" | ||
TOTAL_TIME=$(echo "$TOTAL_TIME + $RUN_TIME" | bc) | ||
else | ||
echo "Error: Unable to capture timing for run $i. Got: $RUN_TIME" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Calculate average time | ||
AVERAGE_TIME=$(echo "scale=3; $TOTAL_TIME / $N" | bc) | ||
echo "Average time for commit $COMMIT: ${AVERAGE_TIME}s" >> $OUTPUT_FILE | ||
echo "-----------------------------------" >> $OUTPUT_FILE | ||
} | ||
|
||
# Time the first commit | ||
time_commit $COMMIT1 $EXAMPLE_NAME $N | ||
|
||
# Time the second commit | ||
time_commit $COMMIT2 $EXAMPLE_NAME $N | ||
|
||
# Switch back to the current branch | ||
git checkout - | ||
|
||
# Output completion message | ||
echo "Timing complete. Results saved to $OUTPUT_FILE." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.