Skip to content

Commit 10a976f

Browse files
authored
chore: increase row count and batch size for more deterministic tests (#9088)
# Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. --> - Closes #NNN. # Rationale for this change Previous benchmark is too fast to deterministically measure the performance improvement because they run only in 2-7 microsecond. <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> # What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> # Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> # Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please call them out. -->
1 parent 2507946 commit 10a976f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arrow-json/benches/serde.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ use rand::{Rng, rng};
2222
use serde::Serialize;
2323
use std::sync::Arc;
2424

25+
const ROWS: usize = 1 << 18;
26+
2527
#[allow(deprecated)]
2628
fn do_bench<R: Serialize>(c: &mut Criterion, name: &str, rows: &[R], schema: &Schema) {
2729
let schema = Arc::new(schema.clone());
2830
c.bench_function(name, |b| {
2931
b.iter(|| {
30-
let builder = ReaderBuilder::new(schema.clone()).with_batch_size(64);
32+
let builder = ReaderBuilder::new(schema.clone()).with_batch_size(8192);
3133
let mut decoder = builder.build_decoder().unwrap();
3234
decoder.serialize(rows)
3335
})
@@ -37,26 +39,26 @@ fn do_bench<R: Serialize>(c: &mut Criterion, name: &str, rows: &[R], schema: &Sc
3739
fn criterion_benchmark(c: &mut Criterion) {
3840
let mut rng = rng();
3941
let schema = Schema::new(vec![Field::new("i32", DataType::Int32, false)]);
40-
let v: Vec<i32> = (0..2048).map(|_| rng.random_range(0..10000)).collect();
42+
let v: Vec<i32> = (0..ROWS).map(|_| rng.random_range(0..10000)).collect();
4143

4244
do_bench(c, "small_i32", &v, &schema);
43-
let v: Vec<i32> = (0..2048).map(|_| rng.random()).collect();
45+
let v: Vec<i32> = (0..ROWS).map(|_| rng.random()).collect();
4446
do_bench(c, "large_i32", &v, &schema);
4547

4648
let schema = Schema::new(vec![Field::new("i64", DataType::Int64, false)]);
47-
let v: Vec<i64> = (0..2048).map(|_| rng.random_range(0..10000)).collect();
49+
let v: Vec<i64> = (0..ROWS).map(|_| rng.random_range(0..10000)).collect();
4850
do_bench(c, "small_i64", &v, &schema);
49-
let v: Vec<i64> = (0..2048)
51+
let v: Vec<i64> = (0..ROWS)
5052
.map(|_| rng.random_range(0..i32::MAX as _))
5153
.collect();
5254
do_bench(c, "medium_i64", &v, &schema);
53-
let v: Vec<i64> = (0..2048).map(|_| rng.random()).collect();
55+
let v: Vec<i64> = (0..ROWS).map(|_| rng.random()).collect();
5456
do_bench(c, "large_i64", &v, &schema);
5557

5658
let schema = Schema::new(vec![Field::new("f32", DataType::Float32, false)]);
57-
let v: Vec<f32> = (0..2048).map(|_| rng.random_range(0.0..10000.)).collect();
59+
let v: Vec<f32> = (0..ROWS).map(|_| rng.random_range(0.0..10000.)).collect();
5860
do_bench(c, "small_f32", &v, &schema);
59-
let v: Vec<f32> = (0..2048).map(|_| rng.random_range(0.0..f32::MAX)).collect();
61+
let v: Vec<f32> = (0..ROWS).map(|_| rng.random_range(0.0..f32::MAX)).collect();
6062
do_bench(c, "large_f32", &v, &schema);
6163
}
6264

0 commit comments

Comments
 (0)