#!/usr/bin/env python3
"""
Naive config validator - no caching.
Profile this to see repeated validate_rule_slow calls.

Usage:
    python3 config_validator_naive.py
    python3 -m cProfile -s tottime config_validator_naive.py
"""

import time

from common import validate_rule_slow, load_events


def process_events(events):
    """Process events using naive repeated validation."""
    valid_count = 0
    for rule_id, event_type, data in events:
        if validate_rule_slow(rule_id, event_type):
            valid_count += 1
    return valid_count


ITERATIONS = 5


def main():
    events = load_events()
    print(f"Processing {len(events)} events (naive), {ITERATIONS} iterations...")

    times = []
    for _ in range(ITERATIONS):
        start = time.perf_counter()
        valid_count = process_events(events)
        times.append(time.perf_counter() - start)

    avg = sum(times) / len(times)
    print(f"Valid: {valid_count}")
    print(f"Avg time: {avg:.3f}s")


if __name__ == "__main__":
    main()
