Add the first use of the rust benchmark tests.
This commit is contained in:
parent
547fc40dbe
commit
72b4cf8e71
@ -2,8 +2,11 @@
|
|||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![feature(path_file_prefix)]
|
#![feature(path_file_prefix)]
|
||||||
#![feature(is_sorted)]
|
#![feature(is_sorted)]
|
||||||
|
#![feature(test)]
|
||||||
// TODO: #![warn(missing_docs)]
|
// TODO: #![warn(missing_docs)]
|
||||||
|
|
||||||
|
extern crate test;
|
||||||
|
|
||||||
#[cfg(feature = "compare")]
|
#[cfg(feature = "compare")]
|
||||||
pub mod compare;
|
pub mod compare;
|
||||||
|
|
||||||
|
@ -250,3 +250,25 @@ fn export_keyword<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>
|
|||||||
take_while1(|c: char| c.is_alphanumeric() || "-_".contains(c)),
|
take_while1(|c: char| c.is_alphanumeric() || "-_".contains(c)),
|
||||||
)))(input)
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use test::Bencher;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use crate::context::Context;
|
||||||
|
use crate::context::ContextElement;
|
||||||
|
use crate::context::GlobalSettings;
|
||||||
|
use crate::context::List;
|
||||||
|
use crate::parser::OrgSource;
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_affiliated_keyword(b: &mut Bencher) {
|
||||||
|
let input = OrgSource::new("#+CAPTION[*foo*]: bar *baz*");
|
||||||
|
let global_settings = GlobalSettings::default();
|
||||||
|
let initial_context = ContextElement::document_context();
|
||||||
|
let initial_context = Context::new(&global_settings, List::new(&initial_context));
|
||||||
|
|
||||||
|
b.iter(|| assert!(affiliated_keyword(&initial_context, input).is_ok()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user