zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-zipkin] adriancole commented on issue #2579: Benchmark bytes / bytebuffer, protobuf vs zipkin vs wire.
Date Fri, 10 May 2019 12:53:54 GMT
adriancole commented on issue #2579: Benchmark bytes / bytebuffer, protobuf vs zipkin vs wire.
URL: https://github.com/apache/incubator-zipkin/pull/2579#issuecomment-491278374
 
 
   cc also @swankjesse as this sort of thing is fun..
   
   I think special peeking aside, it might boil down to if we can manage to read proto bytes
as hex. if we can definitely wire should be better than it is now.. 
   
   I added this to wire's ProtoReader though haven't tested it quite yet
   ```kotlin
     // stolen from okio
     private val HEX_DIGITS =
         charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
'e', 'f')
   
     @Suppress("NOTHING_TO_INLINE")
     internal inline fun hex(data: BufferedSource, byteCount: Int): String {
       val result = CharArray(byteCount * 2)
       var i = 0
       while (i < result.size) {
         val b = data.readByte();
         result[i++] = HEX_DIGITS[b shr 4 and 0xf]
         result[i++] = HEX_DIGITS[b       and 0xf] // ktlint-disable no-multi-spaces
       }
       return String(result)
     }
   
     /**
      * Reads a `bytes` field value from the stream as a lower-hex string. The length is read
from the
      * stream prior to the actual data.
      */
     @Throws(IOException::class)
     fun readBytesAsHex(): String {
       val byteCount = beforeLengthDelimitedScalar()
       source.require(byteCount) // Throws EOFException if insufficient bytes are available.
       return hex(source, byteCount.toInt())
     }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message