Add benchmarks for parser cloning & rc cloning (#17)

This commit is contained in:
folex 2020-11-09 14:20:01 +03:00 committed by GitHub
parent 7cdac944c3
commit cfd5aa7c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 15 deletions

4
Cargo.lock generated
View File

@ -999,7 +999,7 @@ dependencies = [
[[package]]
name = "lalrpop"
version = "0.19.1"
source = "git+https://github.com/fluencelabs/lalrpop#149e77b301828392b09da5c2ba634fd19ce3a3a7"
source = "git+https://github.com/fluencelabs/lalrpop?branch=cloneable_parser#486546b479b51ee370beec1d9e663dcbafa7cab1"
dependencies = [
"ascii-canvas",
"atty",
@ -1023,7 +1023,7 @@ dependencies = [
[[package]]
name = "lalrpop-util"
version = "0.19.1"
source = "git+https://github.com/fluencelabs/lalrpop#149e77b301828392b09da5c2ba634fd19ce3a3a7"
source = "git+https://github.com/fluencelabs/lalrpop?branch=cloneable_parser#486546b479b51ee370beec1d9e663dcbafa7cab1"
dependencies = [
"regex",
]

View File

@ -5,10 +5,10 @@ authors = ["Fluence Labs"]
edition = "2018"
[build-dependencies]
lalrpop = { git = "https://github.com/fluencelabs/lalrpop", version = "0.19.1", features = ["lexer"] }
lalrpop = { git = "https://github.com/fluencelabs/lalrpop", branch = "cloneable_parser", version = "0.19.1", features = ["lexer"] }
[dependencies]
lalrpop-util = { git = "https://github.com/fluencelabs/lalrpop", version = "0.19.1", features = ["lexer"] }
lalrpop-util = { git = "https://github.com/fluencelabs/lalrpop", branch = "cloneable_parser", version = "0.19.1", features = ["lexer"] }
regex = "1.4.1"
codespan = "0.9.5"
codespan-reporting = "0.9.5"

View File

@ -70,10 +70,26 @@ mod gen {
}
}
fn bench_creation(c: &mut Criterion) {
fn create_parser(c: &mut Criterion) {
c.bench_function("create_parser", move |b| b.iter(move || InstrParser::new()));
}
fn clone_parser(c: &mut Criterion) {
let parser = InstrParser::new();
c.bench_function("clone_parser", move |b| {
let parser = parser.clone();
b.iter(move || parser.clone())
});
}
fn clone_parser_rc(c: &mut Criterion) {
let parser = Rc::new(InstrParser::new());
c.bench_function("clone_parser_rc", move |b| {
let parser = parser.clone();
b.iter(move || parser.clone())
});
}
fn parse(c: &mut Criterion) {
let parser = Rc::new(InstrParser::new());
c.bench_function(
@ -126,5 +142,13 @@ fn parse_deep(c: &mut Criterion) {
);
}
criterion_group!(benches, bench_creation, parse, parse_to_fail, parse_deep);
criterion_main!(benches);
criterion_group!(
parser,
create_parser,
parse,
parse_to_fail,
parse_deep,
clone_parser,
clone_parser_rc,
);
criterion_main!(parser);

View File

@ -76,7 +76,7 @@ match {
r"[\w_-]+" => ALPHANUMERIC,
r"[\w_-]+\[\]" => ACCUMULATOR,
r#"[\w_-]+\.*\$([\w._-]*(\[[\w"]+\])*)+"# => JSON_PATH,
"%current_peer_id%" => CURRENT_PEER_ID,
r#"%current_peer_id%"# => CURRENT_PEER_ID,
"seq",
"call",
"null",

File diff suppressed because one or more lines are too long