alamb commented on code in PR #9729:
URL: https://github.com/apache/arrow-rs/pull/9729#discussion_r3118229664
##########
arrow/benches/cast_kernels.rs:
##########
@@ -360,6 +446,303 @@ fn add_benchmark(c: &mut Criterion) {
b.iter(|| cast_array(&binary_view_array, DataType::Utf8View))
});
+ macro_rules! benchmark_cast {
+ ($name: expr, $input_array: ident, $target_type: expr) => {
+ c.bench_function(stringify!($name), |b| {
+ b.iter(|| cast_array(&$input_array, $target_type))
+ });
+ };
+ }
+
+ // cast string with normal items to decimals
+ benchmark_cast!(
+ "cast string to decimal32(9, 2)",
+ string_float_array_normal,
+ DataType::Decimal32(9, 2)
+ );
+ benchmark_cast!(
+ "cast string to decimal64(18, 2)",
+ string_float_array_normal,
+ DataType::Decimal64(18, 2)
+ );
+ benchmark_cast!(
+ "cast string to decimal128(38, 3)",
+ string_float_array_normal,
+ DataType::Decimal128(38, 3)
+ );
+ benchmark_cast!(
+ "cast string to decimal256(76, 4)",
+ string_float_array_normal,
+ DataType::Decimal256(76, 4)
+ );
+
+ // cast invalid string to decimals
+ benchmark_cast!(
+ "cast invalid string to decimal32(9, 2)",
+ invalid_string_float_array,
+ DataType::Decimal32(9, 2)
+ );
+ benchmark_cast!(
+ "cast invalid string to decimal64(18, 2)",
+ invalid_string_float_array,
+ DataType::Decimal64(18, 2)
+ );
+ benchmark_cast!(
+ "cast invalid string to decimal128(38, 3)",
+ invalid_string_float_array,
+ DataType::Decimal128(38, 3)
+ );
+ benchmark_cast!(
+ "cast invalid string to decimal256(76, 4)",
+ invalid_string_float_array,
+ DataType::Decimal256(76, 4)
+ );
+
+ // cast float32 to decimals
+ benchmark_cast!(
+ "cast float32 to decimal32(9, 2)",
+ float32_array_cast_to_decimal,
+ DataType::Decimal32(9, 2)
+ );
+ benchmark_cast!(
+ "cast float32 to decimal64(18, 2",
+ float32_array_cast_to_decimal,
+ DataType::Decimal64(18, 2)
+ );
+ benchmark_cast!(
+ "cast float32 to decimal128(32, 3)",
+ float32_array_cast_to_decimal,
+ DataType::Decimal128(38, 3)
+ );
+ benchmark_cast!(
+ "cast float32 to decimal256(76, 4)",
+ float32_array_cast_to_decimal,
+ DataType::Decimal256(76, 4)
+ );
+
+ // cast invalid float32 to decimals
+ benchmark_cast!(
+ "cast invalid float32 to decimal32(9, 2)",
+ invalid_float32_array_to_decimal,
+ DataType::Decimal32(9, 2)
+ );
+ benchmark_cast!(
Review Comment:
similarly to below, is there benefit to testing the invalid path for all of
the decimal types? Just one probably is enough
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]