adriancole edited a comment 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().toInt();
         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:
[email protected]


With regards,
Apache Git Services

Reply via email to