Skip to content

Instantly share code, notes, and snippets.

@xrl
Created June 1, 2017 00:12
Show Gist options
  • Save xrl/042e2e5e343ea27fe535a2146b62efee to your computer and use it in GitHub Desktop.
Save xrl/042e2e5e343ea27fe535a2146b62efee to your computer and use it in GitHub Desktop.
#[bench]
fn parse_file(b: &mut Bencher) {
use std::fs::{ File };
use std::io::{ Seek, SeekFrom };
let mut f = File::open("/Users/xlange/30ece7c43b7c302f43e54ac9f299ca36efb8184375eac0563c9340a15100ee3c-json.log").unwrap();
b.iter(|| {
{
use std::io::{BufRead, BufReader};
let buf_f = BufReader::new(&f);
for sample in buf_f.lines() {
let line = sample.unwrap();
let _: DockerLogLine = serde_json::from_str(&line[..]).unwrap();
}
}
f.seek(SeekFrom::Start(0)).unwrap();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment