use butteraugli::{butteraugli, ButteraugliParams, Img, RGB8};
use std::time::Instant;

fn main() {
    let width = 512;
    let height = 512;

    // Create gradient images with small differences
    let pixels1: Vec<RGB8> = (0..width * height)
        .map(|i| {
            let x = i % width;
            let val = ((x as f32 / width as f32) * 200.0) as u8;
            RGB8::new(val, val, val)
        })
        .collect();

    let pixels2: Vec<RGB8> = (0..width * height)
        .map(|i| {
            let x = i % width;
            let y = i / width;
            let val = ((x as f32 / width as f32) * 200.0) as u8;
            let val2 = val.saturating_add(((x * y) % 10) as u8);
            RGB8::new(val2, val2, val2)
        })
        .collect();

    let img1 = Img::new(pixels1, width, height);
    let img2 = Img::new(pixels2, width, height);
    let params = ButteraugliParams::default();

    // Warmup
    let _ = butteraugli(img1.as_ref(), img2.as_ref(), &params);

    // Benchmark
    let iterations = 10;
    let start = Instant::now();
    for _ in 0..iterations {
        let _ = butteraugli(img1.as_ref(), img2.as_ref(), &params);
    }
    let elapsed = start.elapsed();

    println!(
        "512x512 image: {:.2}ms per iteration ({} iterations, total {:.2}s)",
        elapsed.as_secs_f64() * 1000.0 / iterations as f64,
        iterations,
        elapsed.as_secs_f64()
    );
}
