Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: added http request grammar #726

Merged
merged 1 commit into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions FUZZING.md
Expand Up @@ -21,11 +21,12 @@ There is a single fuzzing target for this crate that interacts with

### `pest_grammars`

- `http`
- `toml`
- `json`

There are two fuzzing targets for this crate: one tests the json grammar in the
`json` module and the other tests the toml grammar in the `toml` module. They
There are three fuzzing targets for this crate: one tests the http request grammar in the `http` module, one tests the json grammar in the
`json` module and the last one tests the toml grammar in the `toml` module. They
interact directly with the `pest::Parser::parse` function provided by derived
on the respective Parsers in each module.

Expand Down
4 changes: 4 additions & 0 deletions grammars/Cargo.toml
Expand Up @@ -22,4 +22,8 @@ criterion = "0.3"

[[bench]]
name = "json"
harness = false

[[bench]]
name = "http"
harness = false
22 changes: 22 additions & 0 deletions grammars/benches/http.rs
@@ -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);