#!/bin/bash

# Simple Performance Benchmark: Fast vs Regular Random Emitter

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

# Build in release mode
echo "Building in release mode..."
cargo build --release

# Test with 1M events
EVENT_COUNT=1000000

echo "=== Performance Benchmark: 1M Events ==="
echo

echo "Testing Regular Random Emitter..."
time "$PROJECT_ROOT/target/release/wasot" random -n "$EVENT_COUNT" -o regular_test.wasot
REGULAR_SIZE=$(du -h regular_test.wasot | cut -f1)
echo "Regular file size: $REGULAR_SIZE"
rm -f regular_test.wasot

echo
echo "Testing Fast Random Emitter..."
time "$PROJECT_ROOT/target/release/wasot" fast-random -n "$EVENT_COUNT" -o fast_test.wasot
FAST_SIZE=$(du -h fast_test.wasot | cut -f1)
echo "Fast file size: $FAST_SIZE"
rm -f fast_test.wasot

echo
echo "Benchmark complete!"
echo "Regular: Generated $EVENT_COUNT events, file size: $REGULAR_SIZE"
echo "Fast: Generated $EVENT_COUNT events, file size: $FAST_SIZE"