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
kotlinx-benchmark requires benchmark classes to be annotated with @State.
It seems reasonable to expect that when there is a base class annotated with @State providing common routines and state for subclasses, and then it should be enough to simply extend that class w/o explicitly annotating leaf class w/ @State.
Here's an example of such code reuse via inheritance from kotlinx-iobenchmarks:
@State(Scope.Benchmark)
abstractclassBufferRWBenchmarkBase {
protectedval buffer =Buffer()
@Setup funsetupBuffers() { /* some setup common for all subclasses */ }
}
openclassByteBenchmark : BufferRWBenchmarkBase() {
@Benchmark funbenchmark(): Byte {
buffer.writeByte(0x42)
return buffer.readByte()
}
}
openclassShortBenchmark : BufferRWBenchmarkBase() {
@Benchmark funbenchmark(): Short {
buffer.writeShort(42)
return buffer.readShort()
}
}
...
Also, it would be nice to verify that if benchmark-class and its superclass are both annotated w/ @State with the same scope. The condition would be always true now, but may no longer hold in the future.
My expectations regarding State inheritance are based on how it works in JMH, and because that's a different framework it not necessarily should be true for kotlinx-benchmark. However, if the proposal will be rejected, it would be nice to print warning for the classes having @Benchmark-methods, but not annotated w/ the @State.
The text was updated successfully, but these errors were encountered:
kotlinx-benchmark
requires benchmark classes to be annotated with@State
.It seems reasonable to expect that when there is a base class annotated with
@State
providing common routines and state for subclasses, and then it should be enough to simply extend that class w/o explicitly annotating leaf class w/@State
.Here's an example of such code reuse via inheritance from
kotlinx-io
benchmarks:Also, it would be nice to verify that if benchmark-class and its superclass are both annotated w/
@State
with the same scope. The condition would be always true now, but may no longer hold in the future.My expectations regarding State inheritance are based on how it works in JMH, and because that's a different framework it not necessarily should be true for
kotlinx-benchmark
. However, if the proposal will be rejected, it would be nice to print warning for the classes having@Benchmark
-methods, but not annotated w/ the@State
.The text was updated successfully, but these errors were encountered: