alamb commented on code in PR #7434:
URL: https://github.com/apache/arrow-rs/pull/7434#discussion_r2100009708


##########
arrow-avro/benches/avro_reader.rs:
##########
@@ -0,0 +1,271 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Comprehensive benchmarks comparing StringArray vs StringViewArray 
performance
+//!
+//! This benchmark suite compares the performance characteristics of 
StringArray vs
+//! StringViewArray across three key dimensions:
+//! 1. Array creation performance
+//! 2. String value access operations  
+//! 3. Avro file reading with each array type
+
+use std::fs::File;
+use std::io::{BufReader, Read, Write};
+use std::sync::Arc;
+use std::time::Duration;
+
+use arrow::array::RecordBatch;
+use arrow::datatypes::{DataType, Field, Schema};
+use arrow_array::{ArrayRef, Int32Array, StringArray, StringViewArray};
+use arrow_avro::ReadOptions;
+use arrow_schema::ArrowError;
+use criterion::*;
+use tempfile::NamedTempFile;
+
+fn create_test_data(count: usize, str_length: usize) -> Vec<String> {
+    (0..count)
+        .map(|i| format!("str_{}", i) + &"a".repeat(str_length))
+        .collect()
+}
+
+fn create_avro_test_file(row_count: usize, str_length: usize) -> 
Result<NamedTempFile, ArrowError> {
+    let schema = Arc::new(Schema::new(vec![
+        Field::new("string_field", DataType::Utf8, false),
+        Field::new("int_field", DataType::Int32, false),
+    ]));
+
+    let strings = create_test_data(row_count, str_length);
+    let string_array = StringArray::from_iter(strings.iter().map(|s| 
Some(s.as_str())));
+    let int_array = Int32Array::from_iter_values(0..row_count as i32);
+    let _batch = RecordBatch::try_new(
+        schema.clone(),
+        vec![
+            Arc::new(string_array) as ArrayRef,
+            Arc::new(int_array) as ArrayRef,
+        ],
+    )?;
+
+    let temp_file = NamedTempFile::new()?;
+
+    let mut file = temp_file.reopen()?;
+
+    file.write_all(b"AVRO")?;

Review Comment:
   I wondered why this benchmark isn't using a avro writer and then I realized 
it is because there is no writer in avro-arrow 👍 



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

Reply via email to