You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Binary.fromCharSequence is an order of magnitude slower than Binary.fromString when input is a String, this is because CharsetEncoder.encode() is much slower than String.getBytes(charset).
)
`Binary.fromCharSequence` is an order of magnitude slower than `Binary.fromString` when input is a `String`:
```
Benchmarks.fromCharSequence thrpt 25 5885347.328 ± 186669.738 ops/s
Benchmarks.fromString thrpt 25 71335979.492 ± 8800704.044 ops/s
```
Here is the code for the benchmarks:
```java
public class Benchmarks {
private static final String string = RandomStringUtils.randomAlphanumeric(100);
@benchmark
@BenchmarkMode(Mode.Throughput)
public void fromCharSequence(Blackhole blackhole) {
blackhole.consume(Binary.fromCharSequence(string));
}
@benchmark
@BenchmarkMode(Mode.Throughput)
public void fromString(Blackhole blackhole) {
blackhole.consume(Binary.fromString(string));
}
}
```
Describe the enhancement requested
Currently
AvroWriteSupport.fromAvroString
callsBinary.fromCharSequence
when convertingString
toBinary
.Binary.fromCharSequence
is an order of magnitude slower thanBinary.fromString
when input is aString
, this is becauseCharsetEncoder.encode()
is much slower thanString.getBytes(charset)
.benchmark results:
benchmark code:
Component(s)
Avro
The text was updated successfully, but these errors were encountered: