diff --git a/scripts/benchmarks/run-benchmarks-local.sh b/scripts/benchmarks/run-benchmarks-local.sh index 5c1798d..f24241b 100755 --- a/scripts/benchmarks/run-benchmarks-local.sh +++ b/scripts/benchmarks/run-benchmarks-local.sh @@ -33,6 +33,24 @@ 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 +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 "--- tail (last 50 lines) ---" >&2 + tail -n 50 "$NATIVE_RESULTS_FILE" >&2 || true + fi +else + echo "" + echo "Step 1b: Native libraries not found, skipping native benchmarks" + echo " (Build with: make native-build)" +fi + # Extract benchmark results grep "Benchmark.*-[0-9].*" "$BENCHMARK_RESULTS_FILE" > "$RUN_DIR/clean_benchmarks.txt" || true @@ -101,9 +119,17 @@ fi echo "" # Show top 10 results -echo "Top 10 benchmark times:" +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 + echo "" + echo "Native library benchmarks available at: $NATIVE_RESULTS_FILE" + echo "To compare Go vs Native:" + echo " make benchmark-compare" +fi + # Step 5: Generate HTML report echo "Step 5: Generating HTML report..." cat > "$RUN_DIR/report.html" << EOF diff --git a/scripts/ci/test.sh b/scripts/ci/test.sh index 356e20f..95a52d1 100755 --- a/scripts/ci/test.sh +++ b/scripts/ci/test.sh @@ -32,8 +32,7 @@ echo "" echo "[1] Building CLI (native)..." cd "${CLI_DIR}" rm -rf zig-out .zig-cache -mkdir -p zig-out/bin -zig build-exe -OReleaseSmall -fstrip -femit-bin=zig-out/bin/ml src/main.zig +zig build -Doptimize=ReleaseSmall ls -lh zig-out/bin/ml # Optional: cross-target test if your Zig supports it @@ -41,9 +40,8 @@ if command -v zig >/dev/null 2>&1; then echo "" echo "[1b] Testing cross-target (linux-x86_64) if supported..." if zig targets | grep -q x86_64-linux-gnu; then - rm -rf zig-out - mkdir -p zig-out/bin - zig build-exe -OReleaseSmall -fstrip -target x86_64-linux-gnu -femit-bin=zig-out/bin/ml src/main.zig + rm -rf zig-out .zig-cache + zig build -Doptimize=ReleaseSmall -Dtarget=x86_64-linux-gnu ls -lh zig-out/bin/ml else echo "Cross-target x86_64-linux-gnu not available; skipping." diff --git a/scripts/dev/smoke-test.sh b/scripts/dev/smoke-test.sh index f9f6cb8..9182208 100644 --- a/scripts/dev/smoke-test.sh +++ b/scripts/dev/smoke-test.sh @@ -56,17 +56,27 @@ if [[ "$native_mode" == true ]]; then echo "" # Run C++ unit tests - if [[ -f ./native/build/queue_index/test_storage ]]; then - echo "2. Running C++ smoke tests..." - ./native/build/queue_index/test_storage 2>/dev/null || echo " ⚠ C++ tests skipped" - echo "" + echo "2. Running C++ smoke tests..." + local tests_run=0 + for test_bin in ./native/build/test_*; do + if [[ -x "$test_bin" ]]; then + local test_name=$(basename "$test_bin") + echo " Running $test_name..." + "$test_bin" 2>/dev/null && echo " ✓ $test_name passed" || echo " ⚠ $test_name skipped/failed" + ((tests_run++)) + fi + done + if [[ $tests_run -eq 0 ]]; then + echo " ⚠ No C++ tests found" + else + echo " Ran $tests_run C++ test(s)" fi + echo "" - # Build Go with native libs echo "3. Building Go applications with native libs..." - FETCHML_NATIVE_LIBS=1 go build -o /dev/null ./cmd/api-server 2>&1 | grep -v "ignoring duplicate" || true + go build -tags native_libs -o /dev/null ./cmd/api-server 2>&1 | grep -v "ignoring duplicate" || true echo " api-server builds" - FETCHML_NATIVE_LIBS=1 go build -o /dev/null ./cmd/worker 2>&1 | grep -v "ignoring duplicate" || true 2>/dev/null || echo " (worker optional)" + go build -tags native_libs -o /dev/null ./cmd/worker 2>&1 | grep -v "ignoring duplicate" || true 2>/dev/null || echo " (worker optional)" echo "" fi