///|
pub struct BenchmarkReport {
  name : String
  frames : Int
  tags : Int
  slices : Int
  total_duration : Int
  atlas_size : Size
  packed_area : Int
  occupancy : Double
  errors : Int
  warnings : Int
} derive(Debug, Eq, ToJson, FromJson)

///|
pub fn benchmark_report(
  name : String,
  text : String,
  atlas? : AtlasOptions = AtlasOptions::default(),
) -> BenchmarkReport raise {
  let sheet = parse_aseprite_json(text)
  let bundle = build_export_bundle(sheet, atlas~)
  let summary = summarize_diagnostics(bundle.diagnostics)
  {
    name,
    frames: bundle.sheet.frames.length(),
    tags: bundle.sheet.tags.length(),
    slices: bundle.sheet.slices.length(),
    total_duration: total_duration(bundle.sheet),
    atlas_size: bundle.atlas.size,
    packed_area: bundle.atlas.packed_area(),
    occupancy: bundle.atlas.occupancy,
    errors: summary.errors,
    warnings: summary.warnings,
  }
}

///|
pub fn BenchmarkReport::to_json_string(
  self : BenchmarkReport,
  indent? : Int = 2,
) -> String {
  self.to_json().stringify(indent~)
}