Use include_bytes macro to read bench file
@@ -5,6 +5,7 @@ extern crate test;
mod to_html {
use pulldown_cmark::{Parser, Options, html};
+ use std::str::from_utf8;
use std::io::Read;
use std::path::Path;
use std::fs::File;
@@ -16,22 +17,10 @@ mod to_html {
s
}
- fn read_file(filename: &str) -> String {
- let path = Path::new(filename);
- let mut file = match File::open(&path) {
- Err(why) => panic!("couldn't open {}: {}", path.display(), why),
- Ok(file) => file
- };
- let mut s = String::new();
- match file.read_to_string(&mut s) {
- Err(why) => panic!("couldn't open {}: {}", path.display(), why),
- Ok(_) => s
- }
- }
-
#[bench]
fn crdt_empty_options(b: &mut test::Bencher) {
- let input = read_file("./benches/crdt.md");
+ let input_bytes = include_bytes!("crdt.md");
+ let input = from_utf8(input_bytes).unwrap();
let mut opts = Options::empty();
b.iter(|| render_html(&input, opts));
