-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement string parser * Fix regular expression to properly match strings * Refactor string parsing into several functions and added tests * Remove string allocation when handling unicode * Add simple benchmarks for string parsing * Add simple benchmarks for string parsing * Improve unicode parsing * Move `res.push()` outside `match` * Format the code * Use try operator when parsing unicode characters
- Loading branch information
Showing
5 changed files
with
476 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use cel_parser::parse_string; | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
pub fn parse_string_benchmark(c: &mut Criterion) { | ||
let expressions = vec![ | ||
("text", "\"text\""), | ||
("raw", "r\"text\""), | ||
("single unicode escape sequence", "\"\\U0001f431\""), | ||
("single hex escape sequence", "\"\\x0D\""), | ||
("single oct escape sequence", "\"\\015\""), | ||
]; | ||
|
||
for (name, expr) in black_box(&expressions) { | ||
c.bench_function(name, |b| b.iter(|| parse_string(expr))); | ||
} | ||
} | ||
|
||
criterion_group!(benches, parse_string_benchmark); | ||
criterion_main!(benches); |
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
Oops, something went wrong.