//! Encode labels repeatedly.
//!
//! This is basically a benchmark, but doesn't require nightly Rust.

use std::time::Instant;

use obnam::label::*;

// This pretends to be a label that is an encryptd checksum as ASCII. It's
// supposed to be the pessimal case that Obnam will realistically have.
const LABEL: &str = "ccfaec95-7836-11f1-8dc4-44fa6608c261cdef21ed-7836-11f1-a5b9-44fa6608c261ced867bd-7836-11f1-a701-44fa6608c261";

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let n: u32 = std::env::args().nth(1).unwrap().parse()?;
    println!("encode label {n} times");
    let started = Instant::now();
    for _ in 0..n {
        Label::try_from(LABEL)?;
    }
    let elapsed = started.elapsed().as_secs_f64();
    println!("duration {elapsed} seconds");
    println!("labels/s: {}", f64::from(n) / elapsed);

    Ok(())
}
