Skip to content

Commit

Permalink
Add string_dictionary benches for row format (apache#2677)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Oct 3, 2022
1 parent da8f742 commit 8046e07
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion arrow/benches/row_format.rs
Expand Up @@ -22,9 +22,10 @@ extern crate core;
use arrow::array::ArrayRef;
use arrow::datatypes::{DataType, Int64Type, UInt64Type};
use arrow::row::{RowConverter, SortField};
use arrow::util::bench_util::{create_primitive_array, create_string_array_with_len};
use arrow::util::bench_util::{create_primitive_array, create_string_array_with_len, create_string_dict_array};
use criterion::{black_box, Criterion};
use std::sync::Arc;
use arrow_array::types::Int32Type;

fn row_bench(c: &mut Criterion) {
let cols = vec![Arc::new(create_primitive_array::<UInt64Type>(4096, 0.)) as ArrayRef];
Expand Down Expand Up @@ -85,6 +86,46 @@ fn row_bench(c: &mut Criterion) {
});
});

let cols =
vec![Arc::new(create_string_dict_array::<Int32Type>(4096, 0., 100)) as ArrayRef];

c.bench_function("row_batch 4096 string_dictionary(10, 0)", |b| {
b.iter(|| {
let mut converter = RowConverter::new(vec![SortField::new(DataType::Utf8)]);
black_box(converter.convert_columns(&cols))
});
});

let cols =
vec![Arc::new(create_string_dict_array::<Int32Type>(4096, 0., 100)) as ArrayRef];

c.bench_function("row_batch 4096 string_dictionary(30, 0)", |b| {
b.iter(|| {
let mut converter = RowConverter::new(vec![SortField::new(DataType::Utf8)]);
black_box(converter.convert_columns(&cols))
});
});

let cols =
vec![Arc::new(create_string_dict_array::<Int32Type>(4096, 0., 100)) as ArrayRef];

c.bench_function("row_batch 4096 string_dictionary(100, 0)", |b| {
b.iter(|| {
let mut converter = RowConverter::new(vec![SortField::new(DataType::Utf8)]);
black_box(converter.convert_columns(&cols))
});
});

let cols =
vec![Arc::new(create_string_dict_array::<Int32Type>(4096, 0.5, 100)) as ArrayRef];

c.bench_function("row_batch 4096 string_dictionary(100, 0.5)", |b| {
b.iter(|| {
let mut converter = RowConverter::new(vec![SortField::new(DataType::Utf8)]);
black_box(converter.convert_columns(&cols))
});
});

let cols = [
Arc::new(create_string_array_with_len::<i32>(4096, 0.5, 20)) as ArrayRef,
Arc::new(create_string_array_with_len::<i32>(4096, 0., 30)) as ArrayRef,
Expand All @@ -108,6 +149,30 @@ fn row_bench(c: &mut Criterion) {
});
},
);

let cols = [
Arc::new(create_string_dict_array::<Int32Type>(4096, 0.5, 20)) as ArrayRef,
Arc::new(create_string_dict_array::<Int32Type>(4096, 0., 30)) as ArrayRef,
Arc::new(create_string_dict_array::<Int32Type>(4096, 0., 100)) as ArrayRef,
Arc::new(create_primitive_array::<Int64Type>(4096, 0.)) as ArrayRef,
];

let fields = [
SortField::new(DataType::Utf8),
SortField::new(DataType::Utf8),
SortField::new(DataType::Utf8),
SortField::new(DataType::Int64),
];

c.bench_function(
"row_batch 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)",
|b| {
b.iter(|| {
let mut converter = RowConverter::new(fields.to_vec());
black_box(converter.convert_columns(&cols))
});
},
);
}

criterion_group!(benches, row_bench);
Expand Down

0 comments on commit 8046e07

Please sign in to comment.