Browsed by
Tag: jmh

Benchmark : conversion from long to byte[]

Benchmark : conversion from long to byte[]

I’ve been using Kafka a lot lately, and in Kafka a lot of things are byte arrays, even headers! As I have many components that exchange messages, I added headers to help with message tracking, including a timestamp header which has the value System.currentTimeMillis(). So I had to transform a long into a byte array; in a very naive way, I coded this: String.valueOf(System.currentTimeMillis()).getBytes(). But instantiating a String each time a header is created does not seem very optimal to…

Read More Read More