Skip to content

Commit

Permalink
added result generation
Browse files Browse the repository at this point in the history
  • Loading branch information
zutshi committed Jan 1, 2025
1 parent 7ff5096 commit dbd5aaf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: CN Benchmarks
name: Benchmarks
tool: 'customSmallerIsBetter'
output-file-path: examples/benchmark_results.json
# Access token to deploy GitHub Pages branch
Expand Down
14 changes: 0 additions & 14 deletions examples/benchmark_results.json

This file was deleted.

72 changes: 55 additions & 17 deletions examples/run_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,63 @@
#!/bin/bash

# Define the exclude list
exclude_list=("collatz" "overflow" "sha3-chain")

for file in *; do
# Check if the file is in the exclude list
skip=false
for exclude_file in "${exclude_list[@]}"; do
if [[ "$file" == "$exclude_file" ]]; then
skip=true
echo "skipping excluded example: $file"
break
fi
done
# exclusion_list=("collatz" "overflow" "sha3-chain")
exclusion_list=("multi-function" "collatz" "overflow" "sha3-chain" "stdlib" "alloc" "sha3-ex" "sha2-ex" "sha2-chain" "memory-ops")


# If the file is not in the exclude list, process it
if ! $skip; then
if [ -d "$file" ]; then
echo "Running $file"
cargo run --release -p "$file"
# Initialize an array to hold directories
test_directories=()

# Loop through all items in the current directory
for item in *; do
# Check if the item is a directory
if [[ -d "$item" ]]; then
# Check if the directory is not in the exclusion list
if [[ ! " ${exclusion_list[@]} " =~ " $item " ]]; then
# Add the directory to the array
test_directories+=("$item")
fi
fi
done

echo "## List of Tests:"
echo "-----------------"
for dir in "${test_directories[@]}"; do
echo "$dir"
done


# JSON file to store results
output_file="benchmark_results.json"

# Start creating the JSON structure
printf "[\n" > "$output_file"
echo "-----------------"
for i in "${!test_directories[@]}"; do
file="${test_directories[$i]}"

echo "Running $file"
command="cargo run --release -p \"$file\""
# Use `time` to measure execution time

# Measure the execution time using `time`
exec_time=$( (time -p eval "$command") 2>&1 | grep real | awk '{print $2}' )

# Append result to JSON file
printf " {\n" >> "$output_file"
printf " \"name\": \"%s\",\n" "$file" >> "$output_file"
printf " \"unit\": \"s\",\n" >> "$output_file"
printf " \"value\": %.4f,\n" "$exec_time" >> "$output_file"
printf " \"extra\": \"\"\n" >> "$output_file"

# Add a comma if it's not the last entry
if [ $i -lt $((${#test_directories[@]} - 1)) ]; then
printf " },\n" >> "$output_file"
else
printf " }\n" >> "$output_file"
fi

done

# Close the JSON structure
printf "]\n" >> "$output_file"

0 comments on commit dbd5aaf

Please sign in to comment.