Phoenix500526 commented on code in PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#discussion_r3670705498


##########
arrow-ipc/benches/ipc_writer.rs:
##########
@@ -60,6 +64,36 @@ fn criterion_benchmark(c: &mut Criterion) {
         })
     });
 
+    group.bench_function("StreamEncoder/encode_10", |b| {
+        let batch = create_batch(8192, true);
+        b.iter(move || {
+            let mut encoder = 
StreamEncoder::try_new(batch.schema().as_ref()).unwrap();
+            let mut encoded_len = 0;
+            for _ in 0..10 {
+                encoded_len += 
encoded_buffers_len(encoder.encode(&batch).unwrap());
+            }
+            encoded_len += encoded_buffers_len(encoder.finish().unwrap());
+            black_box(encoded_len);
+        })
+    });
+
+    group.bench_function("StreamEncoder/encode_10/zstd", |b| {
+        let batch = create_batch(8192, true);
+        b.iter(move || {
+            let options = IpcWriteOptions::default()
+                .try_with_compression(Some(CompressionType::ZSTD))
+                .unwrap();
+            let mut encoder =
+                StreamEncoder::try_new_with_options(batch.schema().as_ref(), 
options).unwrap();
+            let mut encoded_len = 0;
+            for _ in 0..10 {
+                encoded_len += 
encoded_buffers_len(encoder.encode(&batch).unwrap());
+            }
+            encoded_len += encoded_buffers_len(encoder.finish().unwrap());
+            black_box(encoded_len);

Review Comment:
   Good point. The final length prevents the aggregate from being optimized 
away, but black-boxing the encoded buffers is a better benchmark boundary. I’ll 
update the StreamEncoder cases to black-box the encode / finish results before 
computing the length. Done in 868d643



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