#!/usr/bin/env python3
"""
Generate test events and save to file.
Run this before profiling the validator scripts.
"""

import pickle
import random
import sys

from common import RULES, EVENT_TYPES, EVENTS_FILE


def generate_test_events(n):
    """Generate n random test events."""
    random.seed(42)  # Reproducible
    events = []
    for i in range(n):
        rule_id = random.choice(RULES)
        event_type = random.choice(EVENT_TYPES)
        data = f"event_{i}"
        events.append((rule_id, event_type, data))
    return events


def main():
    n_events = 100000
    if len(sys.argv) > 1:
        n_events = int(sys.argv[1])

    print(f"Generating {n_events} events...")
    events = generate_test_events(n_events)

    with open(EVENTS_FILE, "wb") as f:
        pickle.dump(events, f)

    print(f"Saved to {EVENTS_FILE}")
    print(f"Unique (rule, event_type) combinations: {len(RULES) * len(EVENT_TYPES)}")


if __name__ == "__main__":
    main()
