Created
March 1, 2021 14:27
-
-
Save hqsz/4f66ddb869de4a4bacee10d36d53e554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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