use std::io::Write; use criterion; pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) { let mut table = Vec::with_capacity(*size); for _ in 0..*size { let mut inner = Vec::with_capacity(*size); for i in 0..*size { inner.push(i); } table.push(inner); } b.iter(|| { let mut output = Vec::new(); write!(&mut output, "").unwrap(); for r1 in &table { write!(&mut output, "\n").unwrap(); for r2 in r1 { write!(&mut output, "", col = r2).unwrap(); } write!(&mut output, "\n").unwrap(); } write!(&mut output, "
{col}
").unwrap(); }); } pub fn teams(b: &mut criterion::Bencher<'_>, _: &usize) { let teams = Teams { year: 2015, teams: vec![ Team { name: "Jiangsu".into(), score: 43, }, Team { name: "Beijing".into(), score: 27, }, Team { name: "Guangzhou".into(), score: 22, }, Team { name: "Shandong".into(), score: 12, }, ], }; b.iter(|| { let mut output = Vec::new(); write!( &mut output, " {year}

CSL {year}

" ) .unwrap(); }); } struct Teams { year: u16, teams: Vec, } struct Team { name: String, score: u8, }