Rachelint commented on code in PR #12513:
URL: https://github.com/apache/datafusion/pull/12513#discussion_r1764904554


##########
datafusion/functions/benches/ltrim.rs:
##########
@@ -17,32 +17,216 @@
 
 extern crate criterion;
 
-use arrow::array::{ArrayRef, StringArray};
-use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use arrow::array::{ArrayRef, LargeStringArray, StringArray, StringViewArray};
+use criterion::{
+    black_box, criterion_group, criterion_main, measurement::Measurement, 
BenchmarkGroup,
+    Criterion, SamplingMode,
+};
 use datafusion_common::ScalarValue;
-use datafusion_expr::ColumnarValue;
+use datafusion_expr::{ColumnarValue, ScalarUDF};
 use datafusion_functions::string;
-use std::sync::Arc;
+use rand::{distributions::Alphanumeric, rngs::StdRng, Rng, SeedableRng};
+use std::{fmt, sync::Arc};
 
-fn create_args(size: usize, characters: &str) -> Vec<ColumnarValue> {
-    let iter =
-        std::iter::repeat(format!("{}datafusion{}", characters, 
characters)).take(size);
-    let array = Arc::new(StringArray::from_iter_values(iter)) as ArrayRef;
+pub fn seedable_rng() -> StdRng {
+    StdRng::seed_from_u64(42)
+}
+
+#[derive(Clone, Copy)]
+pub enum StringArrayType {
+    Utf8View,
+    Utf8,
+    LargeUtf8,
+}
+
+impl fmt::Display for StringArrayType {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            StringArrayType::Utf8View => f.write_str("string_view"),
+            StringArrayType::Utf8 => f.write_str("string"),
+            StringArrayType::LargeUtf8 => f.write_str("large_string"),
+        }
+    }
+}
+
+pub fn create_string_array_and_characters(
+    size: usize,
+    characters: &str,
+    trimmed: &str,
+    remaining_len: usize,
+    string_array_type: StringArrayType,
+) -> (ArrayRef, ScalarValue) {
+    let rng = &mut seedable_rng();
+
+    let lens = vec![remaining_len; size];
+    let string_iter = lens.into_iter().map(|len| {

Review Comment:
   Yes, I want to create `size` strings, and each one has `remaining_len` 
lenght.
   🤔 Maybe it is a bit confused, I have improved it and added some comments.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to