Skip to content

Commit 02f3816

Browse files
authored
Merge pull request #130 from Ten0/129_json_benchmark
Add json transcoding benchmarks
2 parents 31a88c7 + b3b3cf8 commit 02f3816

File tree

13 files changed

+320
-56
lines changed

13 files changed

+320
-56
lines changed

Cargo.lock

+95-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Readme.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -171,37 +171,37 @@ The detailed runtimes of the [benchmarks](./serde_arrow/benches/groups/) are lis
171171

172172
| label | time [ms] | arrow2_convert: | serde_arrow::to | serde_arrow::to | arrow_json::Rea |
173173
|------------------------------|-----------|-----------------|-----------------|-----------------|-----------------|
174-
| arrow2_convert::TryIntoArrow | 50.41 | 1.00 | 0.33 | 0.31 | 0.13 |
175-
| serde_arrow::to_arrow2 | 150.91 | 2.99 | 1.00 | 0.94 | 0.40 |
176-
| serde_arrow::to_arrow | 161.25 | 3.20 | 1.07 | 1.00 | 0.43 |
177-
| arrow_json::ReaderBuilder | 375.00 | 7.44 | 2.48 | 2.33 | 1.00 |
174+
| arrow2_convert::TryIntoArrow | 50.25 | 1.00 | 0.33 | 0.30 | 0.13 |
175+
| serde_arrow::to_arrow2 | 152.02 | 3.03 | 1.00 | 0.92 | 0.41 |
176+
| serde_arrow::to_arrow | 164.94 | 3.28 | 1.09 | 1.00 | 0.44 |
177+
| arrow_json::ReaderBuilder | 375.15 | 7.47 | 2.47 | 2.27 | 1.00 |
178178

179179
### complex_common_serialize(1000000)
180180

181181
| label | time [ms] | arrow2_convert: | serde_arrow::to | serde_arrow::to | arrow_json::Rea |
182182
|------------------------------|-----------|-----------------|-----------------|-----------------|-----------------|
183-
| arrow2_convert::TryIntoArrow | 470.21 | 1.00 | 0.32 | 0.30 | 0.13 |
184-
| serde_arrow::to_arrow2 | 1448.66 | 3.08 | 1.00 | 0.92 | 0.40 |
185-
| serde_arrow::to_arrow | 1574.82 | 3.35 | 1.09 | 1.00 | 0.43 |
186-
| arrow_json::ReaderBuilder | 3628.26 | 7.72 | 2.50 | 2.30 | 1.00 |
183+
| arrow2_convert::TryIntoArrow | 475.17 | 1.00 | 0.32 | 0.30 | 0.13 |
184+
| serde_arrow::to_arrow2 | 1464.57 | 3.08 | 1.00 | 0.92 | 0.40 |
185+
| serde_arrow::to_arrow | 1584.39 | 3.33 | 1.08 | 1.00 | 0.43 |
186+
| arrow_json::ReaderBuilder | 3656.23 | 7.69 | 2.50 | 2.31 | 1.00 |
187187

188188
### primitives_serialize(100000)
189189

190190
| label | time [ms] | arrow2_convert: | serde_arrow::to | serde_arrow::to | arrow_json::Rea |
191191
|------------------------------|-----------|-----------------|-----------------|-----------------|-----------------|
192-
| arrow2_convert::TryIntoArrow | 14.11 | 1.00 | 0.46 | 0.32 | 0.11 |
193-
| serde_arrow::to_arrow2 | 30.85 | 2.19 | 1.00 | 0.70 | 0.25 |
194-
| serde_arrow::to_arrow | 44.02 | 3.12 | 1.43 | 1.00 | 0.35 |
195-
| arrow_json::ReaderBuilder | 125.16 | 8.87 | 4.06 | 2.84 | 1.00 |
192+
| arrow2_convert::TryIntoArrow | 13.12 | 1.00 | 0.40 | 0.29 | 0.10 |
193+
| serde_arrow::to_arrow2 | 32.46 | 2.47 | 1.00 | 0.71 | 0.25 |
194+
| serde_arrow::to_arrow | 45.47 | 3.47 | 1.40 | 1.00 | 0.35 |
195+
| arrow_json::ReaderBuilder | 130.77 | 9.97 | 4.03 | 2.88 | 1.00 |
196196

197197
### primitives_serialize(1000000)
198198

199199
| label | time [ms] | arrow2_convert: | serde_arrow::to | serde_arrow::to | arrow_json::Rea |
200200
|------------------------------|-----------|-----------------|-----------------|-----------------|-----------------|
201-
| arrow2_convert::TryIntoArrow | 144.14 | 1.00 | 0.43 | 0.33 | 0.11 |
202-
| serde_arrow::to_arrow2 | 333.09 | 2.31 | 1.00 | 0.75 | 0.24 |
203-
| serde_arrow::to_arrow | 441.65 | 3.06 | 1.33 | 1.00 | 0.32 |
204-
| arrow_json::ReaderBuilder | 1362.27 | 9.45 | 4.09 | 3.08 | 1.00 |
201+
| arrow2_convert::TryIntoArrow | 151.80 | 1.00 | 0.44 | 0.32 | 0.11 |
202+
| serde_arrow::to_arrow2 | 344.82 | 2.27 | 1.00 | 0.73 | 0.25 |
203+
| serde_arrow::to_arrow | 473.56 | 3.12 | 1.37 | 1.00 | 0.34 |
204+
| arrow_json::ReaderBuilder | 1403.08 | 9.24 | 4.07 | 2.96 | 1.00 |
205205

206206
<!-- end:benchmarks -->
207207

serde_arrow/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212
bench = false
1313

1414
[[bench]]
15-
name = "arrow2"
15+
name = "serde_arrow_bench"
1616
# arrow-version:replace: required-features = ["arrow2-0-17", "arrow-{version}"]
1717
required-features = ["arrow2-0-17", "arrow-50"]
1818
harness = false
@@ -128,6 +128,8 @@ bigdecimal = {version = "0.4", features = ["serde"] }
128128
arrow-json-50 = { package = "arrow-json", version = "50" }
129129
criterion = "0.4"
130130
arrow2_convert = "0.5.0"
131+
serde-transcode = "1"
132+
simd-json = "0.13.8"
131133

132134
[dev-dependencies.rust_decimal]
133135
version = "1.33"

serde_arrow/benches/groups/complex_common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
1010
use serde_arrow::_impl::arrow2;
1111

1212
#[derive(Debug, Serialize, Deserialize, ArrowField, ArrowSerialize, ArrowDeserialize)]
13-
struct Item {
13+
pub struct Item {
1414
string: String,
1515
points: Vec<Point>,
1616
child: SubItem,
@@ -30,7 +30,7 @@ struct SubItem {
3030
}
3131

3232
impl Item {
33-
fn random<R: Rng + ?Sized>(rng: &mut R) -> Self {
33+
pub fn random<R: Rng + ?Sized>(rng: &mut R) -> Self {
3434
let n_string = Uniform::new(1, 50).sample(rng);
3535
let n_points = Uniform::new(1, 50).sample(rng);
3636

serde_arrow/benches/groups/impls.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ macro_rules! define_benchmark {
1616

1717
for n in [$($n),*] {
1818
let mut group = c.benchmark_group(format!("{}_serialize({})", stringify!($name), n));
19-
group.sample_size(20);
19+
2020
group.sampling_mode(criterion::SamplingMode::Flat);
21-
group.measurement_time(std::time::Duration::from_secs(120));
21+
if !crate::groups::impls::is_quick() {
22+
group.sample_size(20);
23+
group.measurement_time(std::time::Duration::from_secs(120));
24+
} else {
25+
group.sample_size(10);
26+
group.measurement_time(std::time::Duration::from_secs(5));
27+
}
28+
29+
let n_items = if !crate::groups::impls::is_quick() { n } else { n / 1000 };
2230

2331
let mut rng = rand::thread_rng();
24-
let items = (0..n)
32+
let items = (0..n_items)
2533
.map(|_| <$ty>::random(&mut rng))
2634
.collect::<Vec<_>>();
2735
let schema = SerdeArrowSchema::from_samples(&items, Default::default()).unwrap();
@@ -166,3 +174,7 @@ pub fn random_string<R: Rng + ?Sized>(rng: &mut R, length: Range<usize>) -> Stri
166174
.map(|_| -> char { Standard.sample(rng) })
167175
.collect()
168176
}
177+
178+
pub fn is_quick() -> bool {
179+
std::env::var("SERDE_ARROW_BENCH_QUICK").is_ok()
180+
}

0 commit comments

Comments
 (0)