mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 18:44:07 +02:00
format
This commit is contained in:
parent
ecbaf4c336
commit
f96b81aa3a
5 changed files with 28 additions and 17 deletions
|
|
@ -1,12 +1,15 @@
|
|||
use php_literal_parser::{from_str, Value};
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use php_literal_parser::{from_str, Value};
|
||||
|
||||
fn perf_parse_int_basic(b: &mut Criterion) {
|
||||
let input = "12345676";
|
||||
|
||||
b.bench_function("parse int", |b| {
|
||||
b.iter(|| {
|
||||
assert_eq!(black_box(from_str::<Value>(black_box(input)).unwrap()), 12345676);
|
||||
assert_eq!(
|
||||
black_box(from_str::<Value>(black_box(input)).unwrap()),
|
||||
12345676
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -14,7 +17,7 @@ fn perf_parse_int_basic(b: &mut Criterion) {
|
|||
fn perf_str_double_basic(b: &mut Criterion) {
|
||||
let input = r#""aut dolores excepturi rerum est velit ad natus eveniet quo tenetur et fugiat sit velit ipsam nesciunt sint et architecto""#;
|
||||
|
||||
b.bench_function("parse double quote string without escapes",|b| {
|
||||
b.bench_function("parse double quote string without escapes", |b| {
|
||||
b.iter(|| {
|
||||
assert!(black_box(from_str::<Value>(black_box(input)).unwrap()).is_string());
|
||||
});
|
||||
|
|
@ -46,10 +49,19 @@ fn perf_str_single_escape(b: &mut Criterion) {
|
|||
|
||||
b.bench_function("parse single quote escaped string", |b| {
|
||||
b.iter(|| {
|
||||
assert!(black_box(from_str::<Value>(black_box(input)).unwrap().is_string()));
|
||||
assert!(black_box(
|
||||
from_str::<Value>(black_box(input)).unwrap().is_string()
|
||||
));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, perf_str_single_escape, perf_str_single_basic, perf_str_double_escape, perf_str_double_basic, perf_parse_int_basic);
|
||||
criterion_main!(benches);
|
||||
criterion_group!(
|
||||
benches,
|
||||
perf_str_single_escape,
|
||||
perf_str_single_basic,
|
||||
perf_str_double_escape,
|
||||
perf_str_double_basic,
|
||||
perf_parse_int_basic
|
||||
);
|
||||
criterion_main!(benches);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue