//! Time repeated per-ship decodes of one container, as the viewer does.
use std::collections::HashSet;
use std::time::Instant;
use sylpheed_formats::mesh::Xbg7Model;
use sylpheed_formats::ship::{is_base_part, ship_id_of};
fn main() {
    let a: Vec<String> = std::env::args().collect();
    let bytes = std::fs::read(&a[1]).unwrap();
    let names = sylpheed_formats::mesh::xbg7_resource_names(&bytes);
    let ids: Vec<String> = {
        let mut v: Vec<String> = names.iter().filter(|n| is_base_part(n))
            .filter_map(|n| ship_id_of(n).map(|s| s.to_string())).collect();
        v.sort(); v.dedup(); v.truncate(5); v
    };
    for id in &ids {
        let want: HashSet<String> = names.iter()
            .filter(|n| ship_id_of(n) == Some(id.as_str())).cloned().collect();
        let t = Instant::now();
        let got = Xbg7Model::models_named(&bytes, &want, &|| false);
        println!("{id}: {} models in {:?}", got.len(), t.elapsed());
    }
}
