use std::fmt;
use std::time::Instant;
struct Struct {
data: [u8; 32],
}
impl fmt::Display for Struct {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self.data)
}
}
fn main() {
println!("flexi_logger");
flexi_logger::Logger::try_with_str("off")
.unwrap()
.format(flexi_logger::detailed_format)
.start()
.unwrap();
let mut structs = Vec::new();
for i in 0..100 {
structs.push(Struct {
data: [i as u8; 32],
});
}
{
let start = Instant::now();
for s in &structs {
log::info!("{}", format!("{}", s));
}
eprintln!("with format: {:?}", start.elapsed()); }
{
let start = Instant::now();
for s in &structs {
log::info!("{}", s);
}
eprintln!("plain: {:?}", start.elapsed()); }
}