Skip to content

Instantly share code, notes, and snippets.

@hqsz
Created March 1, 2021 14:27
Show Gist options
  • Save hqsz/4f66ddb869de4a4bacee10d36d53e554 to your computer and use it in GitHub Desktop.
Save hqsz/4f66ddb869de4a4bacee10d36d53e554 to your computer and use it in GitHub Desktop.
#![feature(test)]
extern crate test;
#[cfg(test)]
mod benchs {
use crate::parser;
use std::{fs::File, io::Read};
use test::Bencher;
macro_rules! bench_source {
() => {{
let mut f = File::open("data/canada.json").unwrap();
let mut source = String::new();
f.read_to_string(&mut source).unwrap();
source
}}
}
#[bench]
fn with_mini(b: &mut Bencher) {
let source = bench_source!();
b.iter(|| {
let _ = parser::parse(&source);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment