Skip to content

Commit

Permalink
Refactor block script
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Dec 4, 2024
1 parent a37ff13 commit 1f5bcb4
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions scripts/benchmark_block.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
#!/usr/bin/env bash

START=874000
END=874009
NET=mainnet
LAPS=100
usage() {
cat <<EOF
Usage: $0 <start> <end> <net> <laps>
Benches a block range
- Saves output to native-<start>-<end>-<net> and vm-<start>-<end>-<net>
- Prints speedup
EOF
}

if ! [ "$#" -ge "4" ]; then
usage
exit 1
fi


START=$1
END=$2
NET=$3
LAPS=$4

output="block-$START-$END-$NET.jsonl"
native_output="native-$output"
vm_output="vm-$output"

echo "Executing with Native"
cargo run --release --features benchmark,structured_logging bench-block-range "$START" "$END" "$NET" "$LAPS" > "$native_output"

native_time=$(tail -n1 "$native_output" | jq .fields.average_run_time)
echo "Average Native time: $native_time"

echo "Executing with VM"
cargo run --release --features benchmark,structured_logging,only_cairo_vm bench-block-range "$START" "$END" "$NET" "$LAPS" > "$vm_output"

cargo run --release --features benchmark,structured_logging bench-block-range $START $END $NET $LAPS | tee "native-$output"
vm_time=$(tail -n1 "$vm_output" | jq .fields.average_run_time)
echo "Average VM time: $vm_time"

cargo run --release --features benchmark,structured_logging,only_cairo_vm bench-block-range $START $END $NET $LAPS | tee "vm-$output"
speedup=$(bc -l <<< "$vm_time/$native_time")
echo "Native Speedup: $speedup"

0 comments on commit 1f5bcb4

Please sign in to comment.