You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2019/02/15 09:09:46 UTC

[tinkerpop] branch master updated: More serialization benchmarks

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 555d726  More serialization benchmarks
555d726 is described below

commit 555d726d1937e4e4213890e4e8c51f189475f724
Author: Jorge Bay Gondra <jo...@gmail.com>
AuthorDate: Fri Feb 15 10:09:10 2019 +0100

    More serialization benchmarks
---
 .../gremlin/driver/SerializationBenchmark.java     | 52 +++++++++++++++++++++-
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
index d68b8ab..d919add 100644
--- a/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
+++ b/gremlin-tools/gremlin-benchmark/src/main/java/org/apache/tinkerpop/gremlin/driver/SerializationBenchmark.java
@@ -19,13 +19,18 @@
 package org.apache.tinkerpop.gremlin.driver;
 
 import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.Unpooled;
 import org.apache.tinkerpop.benchmark.util.AbstractBenchmarkBase;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1;
 import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0;
 import org.apache.tinkerpop.gremlin.driver.ser.SerializationException;
 import org.apache.tinkerpop.gremlin.driver.ser.binary.DataType;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.openjdk.jmh.annotations.Benchmark;
 
 import java.nio.charset.StandardCharsets;
@@ -46,7 +51,7 @@ public class SerializationBenchmark extends AbstractBenchmarkBase {
 
     private static final ByteBuf RequestMessageBinaryBuffer1 = Unpooled.wrappedBuffer(new byte[]{
             // flag
-            0x1,
+            (byte)0x81,
             // uuid
             (byte) 0xd3, (byte) 0xfd, 0x35, 0x40, 0x67, 0x18, 0x46, (byte) 0x87,(byte) 0x95, 0x6b, (byte) 0xc8, 0x61,
             (byte) 0x8a, 0x26, (byte) 0xe3, 0x35,
@@ -60,7 +65,7 @@ public class SerializationBenchmark extends AbstractBenchmarkBase {
 
     private static final ByteBuf RequestMessageBinaryBuffer2 = Unpooled.wrappedBuffer(new byte[]{
             // flag
-            0x1,
+            (byte)0x81,
             // uuid
             (byte) 0xd3, (byte) 0xfd, 0x35, 0x40, 0x67, 0x18, 0x46, (byte) 0x87,(byte) 0x95, 0x6b, (byte) 0xc8, 0x61,
             (byte) 0x8a, 0x26, (byte) 0xe3, 0x35,
@@ -90,9 +95,26 @@ public class SerializationBenchmark extends AbstractBenchmarkBase {
 
     private static final UUID id = UUID.randomUUID();
 
+    private static final ResponseMessage response = ResponseMessage
+            .build(UUID.randomUUID()).code(ResponseStatusCode.SUCCESS).result(new ReferenceVertex(1, "person"))
+            .create();
+
+    private static final Bytecode bytecode = new Bytecode();
+    private static final RequestMessage request = RequestMessage
+            .build(Tokens.OPS_BYTECODE).processor("traversal").overrideRequestId(UUID.randomUUID())
+            .add(Tokens.ARGS_GREMLIN, bytecode)
+            .create();
+
     private static final GraphBinaryMessageSerializerV1 binarySerializer = new GraphBinaryMessageSerializerV1();
     private static final GraphSONMessageSerializerV3d0 graphsonSerializer = new GraphSONMessageSerializerV3d0();
 
+    static {
+        bytecode.addStep("V");
+        bytecode.addStep("values", "name");
+        bytecode.addStep("order");
+        bytecode.addStep("tail", 5);
+    }
+
     @Benchmark
     public RequestMessage testReadMessage1Binary() throws SerializationException {
         RequestMessageBinaryBuffer1.readerIndex(0);
@@ -119,6 +141,32 @@ public class SerializationBenchmark extends AbstractBenchmarkBase {
     }
 
     @Benchmark
+    public void testWriteResponseBinary() throws SerializationException {
+        ByteBuf buffer = binarySerializer.serializeResponseAsBinary(response, ByteBufAllocator.DEFAULT);
+        buffer.release();
+    }
+
+    @Benchmark
+    public void testWriteResponseGraphSON() throws SerializationException {
+        ByteBuf buffer = graphsonSerializer.serializeResponseAsBinary(response, ByteBufAllocator.DEFAULT);
+        buffer.release();
+    }
+
+    @Benchmark
+    public void testWriteBytecodeBinary() throws SerializationException {
+
+        ByteBuf buffer = binarySerializer.serializeRequestAsBinary(request, ByteBufAllocator.DEFAULT);
+        buffer.release();
+    }
+
+    @Benchmark
+    public void testWriteBytecodeGraphSON() throws SerializationException {
+
+        ByteBuf buffer = graphsonSerializer.serializeRequestAsBinary(request, ByteBufAllocator.DEFAULT);
+        buffer.release();
+    }
+
+    @Benchmark
     public RequestMessage testInstanceCreation() {
         return RequestMessage.build("a").overrideRequestId(id).processor("b").create();
     }