This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 87aefa2  AVRO-2701: Add JMH BlackHole to RecordTest (#781)
87aefa2 is described below

commit 87aefa28ad6cb11ab95010cdeac2223cfb701c0d
Author: belugabehr <[email protected]>
AuthorDate: Sun Mar 29 06:39:10 2020 -0400

    AVRO-2701: Add JMH BlackHole to RecordTest (#781)
    
    Co-authored-by: David Mollitor <[email protected]>
---
 .../apache/avro/perf/test/record/RecordTest.java   | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git 
a/lang/java/perf/src/main/java/org/apache/avro/perf/test/record/RecordTest.java 
b/lang/java/perf/src/main/java/org/apache/avro/perf/test/record/RecordTest.java
index ab1db14..1f3b5eb 100644
--- 
a/lang/java/perf/src/main/java/org/apache/avro/perf/test/record/RecordTest.java
+++ 
b/lang/java/perf/src/main/java/org/apache/avro/perf/test/record/RecordTest.java
@@ -33,6 +33,7 @@ import org.openjdk.jmh.annotations.OperationsPerInvocation;
 import org.openjdk.jmh.annotations.Scope;
 import org.openjdk.jmh.annotations.Setup;
 import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
 
 public class RecordTest {
 
@@ -43,16 +44,23 @@ public class RecordTest {
 
   @Benchmark
   @OperationsPerInvocation(BasicState.BATCH_SIZE)
-  public void decode(final TestStateDecode state) throws Exception {
+  public void decode(final TestStateDecode state, final Blackhole blackHole) 
throws Exception {
     final Decoder d = state.decoder;
+    double sd = 0.0;
+    int si = 0;
+
     for (int i = 0; i < state.getBatchSize(); i++) {
-      d.readDouble();
-      d.readDouble();
-      d.readDouble();
-      d.readInt();
-      d.readInt();
-      d.readInt();
+      sd += d.readDouble();
+      sd += d.readDouble();
+      sd += d.readDouble();
+
+      si += d.readInt();
+      si += d.readInt();
+      si += d.readInt();
     }
+
+    blackHole.consume(sd);
+    blackHole.consume(si);
   }
 
   @State(Scope.Thread)

Reply via email to