diff --git a/scripts/benchmarks/run-benchmarks-local.sh b/scripts/benchmarks/run-benchmarks-local.sh index f5c419a..b39b2d3 100755 --- a/scripts/benchmarks/run-benchmarks-local.sh +++ b/scripts/benchmarks/run-benchmarks-local.sh @@ -33,24 +33,41 @@ if [ "$GO_TEST_EXIT_CODE" -ne 0 ]; then tail -n 50 "$BENCHMARK_RESULTS_FILE" >&2 || true fi -# Step 1b: Run native library benchmarks if available -NATIVE_RESULTS_FILE="$RUN_DIR/native_benchmark_results.txt" -NATIVE_EXIT_CODE=0 +# Step 1b: Run C++ native library benchmarks if available +NATIVE_CPP_RESULTS_FILE="$RUN_DIR/native_cpp_benchmark_results.txt" +NATIVE_CPP_EXIT_CODE=0 if [[ -f "native/build/libqueue_index.dylib" || -f "native/build/libqueue_index.so" ]]; then echo "" - echo "Step 1b: Running native library benchmarks..." - CGO_ENABLED=1 go test -tags native_libs -bench=. -benchmem ./tests/benchmarks/... >"$NATIVE_RESULTS_FILE" 2>&1 || NATIVE_EXIT_CODE=$? - if [ "$NATIVE_EXIT_CODE" -ne 0 ]; then - echo "Native benchmark run exited non-zero (exit code: $NATIVE_EXIT_CODE)." >&2 + echo "Step 1b: Running C++ native library benchmarks..." + CGO_ENABLED=1 go test -tags native_libs -bench=. -benchmem ./tests/benchmarks/... >"$NATIVE_CPP_RESULTS_FILE" 2>&1 || NATIVE_CPP_EXIT_CODE=$? + if [ "$NATIVE_CPP_EXIT_CODE" -ne 0 ]; then + echo "C++ native benchmark run exited non-zero (exit code: $NATIVE_CPP_EXIT_CODE)." >&2 echo "--- tail (last 50 lines) ---" >&2 - tail -n 50 "$NATIVE_RESULTS_FILE" >&2 || true + tail -n 50 "$NATIVE_CPP_RESULTS_FILE" >&2 || true fi else echo "" - echo "Step 1b: Native libraries not found, skipping native benchmarks" + echo "Step 1b: C++ native libraries not found, skipping C++ benchmarks" echo " (Build with: make native-build)" fi +# Step 1c: Run Rust native library benchmarks if available +NATIVE_RUST_RESULTS_FILE="$RUN_DIR/native_rust_benchmark_results.txt" +NATIVE_RUST_EXIT_CODE=0 +if [[ -f "native_rust/target/release/libqueue_index.dylib" || -f "native_rust/target/release/libqueue_index.so" ]]; then + echo "" + echo "Step 1c: Running Rust native library benchmarks..." + cd native_rust && cargo bench 2>&1 | tee ../"$NATIVE_RUST_RESULTS_FILE" || NATIVE_RUST_EXIT_CODE=$? + cd .. + if [ "$NATIVE_RUST_EXIT_CODE" -ne 0 ]; then + echo "Rust benchmark run exited non-zero (exit code: $NATIVE_RUST_EXIT_CODE)." >&2 + fi +else + echo "" + echo "Step 1c: Rust native libraries not found, skipping Rust benchmarks" + echo " (Build with: make rust-build)" +fi + # Extract benchmark results grep "Benchmark.*-[0-9].*" "$BENCHMARK_RESULTS_FILE" >"$RUN_DIR/clean_benchmarks.txt" || true @@ -123,9 +140,14 @@ echo "Top 10 Go benchmark times:" cat "$RUN_DIR/prometheus_metrics.txt" | grep "benchmark_time_per_op" | head -10 # Show native comparison if available -if [[ -f "$NATIVE_RESULTS_FILE" && "$NATIVE_EXIT_CODE" -eq 0 ]]; then +if [[ -f "$NATIVE_CPP_RESULTS_FILE" && "$NATIVE_CPP_EXIT_CODE" -eq 0 ]]; then echo "" - echo "Native library benchmarks available at: $NATIVE_RESULTS_FILE" + echo "C++ native library benchmarks available at: $NATIVE_CPP_RESULTS_FILE" +fi +if [[ -f "$NATIVE_RUST_RESULTS_FILE" && "$NATIVE_RUST_EXIT_CODE" -eq 0 ]]; then + echo "Rust native library benchmarks available at: $NATIVE_RUST_RESULTS_FILE" +fi +if [[ ( -f "$NATIVE_CPP_RESULTS_FILE" && "$NATIVE_CPP_EXIT_CODE" -eq 0 ) || ( -f "$NATIVE_RUST_RESULTS_FILE" && "$NATIVE_RUST_EXIT_CODE" -eq 0 ) ]]; then echo "To compare Go vs Native:" echo " make benchmark-compare" fi