-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plus tests, benchmark and a fuzzing target based on #372 by @adamAndMath Closes #210 Co-authored-by: Adam <adam.and.math@gmail.com>
- Loading branch information
1 parent
d5fa6eb
commit b53007b
Showing
10 changed files
with
639 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,8 @@ criterion = "0.3" | |
|
||
[[bench]] | ||
name = "json" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "http" | ||
harness = false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
use pest::Parser; | ||
|
||
use pest_grammars::http::*; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut file = File::open("benches/requests.http").unwrap(); | ||
let mut data = String::new(); | ||
|
||
file.read_to_string(&mut data).unwrap(); | ||
|
||
c.bench_function("http parser", |b| { | ||
b.iter(|| HttpParser::parse(Rule::http, &data).unwrap()) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark,); | ||
criterion_main!(benches); |
Oops, something went wrong.