Skip to content

Commit 8d82534

Browse files
committed
perf: Improve parse json performance
1 parent ba7bc86 commit 8d82534

File tree

14 files changed

+1289
-345
lines changed

14 files changed

+1289
-345
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ jobs:
2424
run: cargo build --verbose
2525
- name: Run tests
2626
run: cargo test --verbose
27+
- name: Run tests disable arbitrary_precision
28+
run: cargo test --no-default-features --features databend --verbose

benches/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::io::Read;
1818
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
1919

2020
fn parse_jsonb(data: &[u8]) {
21-
let _v: jsonb::Value = jsonb::parse_value(data).unwrap();
21+
let _v: jsonb::OwnedJsonb = jsonb::parse_owned_jsonb(data).unwrap();
2222
}
2323

2424
fn parse_serde_json(data: &[u8]) {
@@ -46,20 +46,20 @@ fn add_benchmark(c: &mut Criterion) {
4646
let file = format!("{}", path.unwrap().path().display());
4747
let bytes = read(&file);
4848

49-
c.bench_function(&format!("jsonb parse {}", file), |b| {
49+
c.bench_function(&format!("jsonb parse {file}"), |b| {
5050
b.iter(|| parse_jsonb(&bytes))
5151
});
5252

53-
c.bench_function(&format!("serde_json parse {}", file), |b| {
53+
c.bench_function(&format!("serde_json parse {file}"), |b| {
5454
b.iter(|| parse_serde_json(&bytes))
5555
});
5656

57-
c.bench_function(&format!("json_deserializer parse {}", file), |b| {
57+
c.bench_function(&format!("json_deserializer parse {file}"), |b| {
5858
b.iter(|| parse_json_deserializer(&bytes))
5959
});
6060

6161
let bytes = bytes.clone();
62-
c.bench_function(&format!("simd_json parse {}", file), move |b| {
62+
c.bench_function(&format!("simd_json parse {file}"), move |b| {
6363
b.iter_batched(
6464
|| bytes.clone(),
6565
|mut data| parse_simd_json(&mut data),

benches/strip_nulls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ fn add_benchmark(c: &mut Criterion) {
6262
let bytes = read(&file);
6363
let json = from_slice(&bytes).unwrap().to_vec();
6464

65-
c.bench_function(&format!("strip_nulls_deser[{}]", file), |b| {
65+
c.bench_function(&format!("strip_nulls_deser[{file}]"), |b| {
6666
b.iter(|| strip_nulls_deser(&json));
6767
});
6868

69-
c.bench_function(&format!("strip_nulls_fast[{}]", file), |b| {
69+
c.bench_function(&format!("strip_nulls_fast[{file}]"), |b| {
7070
b.iter(|| strip_nulls_fast(&json));
7171
});
7272
}

0 commit comments

Comments
 (0)