///|
test "package name benchmark" (b : @bench.T) {
  b.bench(fn() { ignore(package_name()) })
}

///|
// Generate a test PNG for benchmarking (64x64 RGBA)
fn make_bench_png() -> Bytes {
  let width = 64
  let height = 64
  let buf = FixedArray::make(width * height * 4, b'\x00')
  for y in 0.. panic()
  }
}

///|
fn make_bench_image() -> ImageData {
  let width = 64
  let height = 64
  let buf = FixedArray::make(width * height * 4, b'\x00')
  for y in 0.. () } })
}

///|
test "bench: PNG encode 64x64" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(encode_png(img)) catch { _ => () } })
}

///|
test "bench: JPEG encode 64x64" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(encode_jpeg(img)) catch { _ => () } })
}

///|
test "bench: PNG roundtrip 64x64" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() {
    try {
      let png = encode_png(img)
      b.keep(decode_png(png))
    } catch {
      _ => ()
    }
  })
}

///|
test "bench: resize nearest 64x64 -> 128x128" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 128, 128, Nearest)) catch { _ => () } })
}

///|
test "bench: resize bilinear 64x64 -> 128x128" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 128, 128, Bilinear)) catch { _ => () } })
}

///|
test "bench: resize bicubic 64x64 -> 128x128" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 128, 128, Bicubic)) catch { _ => () } })
}

///|
test "bench: resize nearest 64x64 -> 32x32" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 32, 32, Nearest)) catch { _ => () } })
}

///|
test "bench: resize bilinear 64x64 -> 32x32" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 32, 32, Bilinear)) catch { _ => () } })
}

///|
test "bench: resize bicubic 64x64 -> 32x32" (b : @bench.T) {
  let img = make_bench_image()
  b.bench(fn() { b.keep(resize(img, 32, 32, Bicubic)) catch { _ => () } })
}