Skip to content

Commit fc5d257

Browse files
authored
Switching FrameType flags back to bits (rsocket#548)
* switching frame type flag back to bits so we don't have to traverse an array when looking up flags Signed-off-by: Robert Roeser <rroeserr@gmail.com> * jmh test Signed-off-by: Robert Roeser <rroeserr@gmail.com> * Added an EMPTY flag Signed-off-by: Robert Roeser <rroeserr@gmail.com>
1 parent 22acd9c commit fc5d257

File tree

3 files changed

+139
-108
lines changed

3 files changed

+139
-108
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.rsocket.framing;
2+
3+
import org.openjdk.jmh.annotations.*;
4+
import org.openjdk.jmh.infra.Blackhole;
5+
6+
@BenchmarkMode(Mode.Throughput)
7+
@Fork(
8+
value = 1 // , jvmArgsAppend = {"-Dio.netty.leakDetection.level=advanced"}
9+
)
10+
@Warmup(iterations = 10)
11+
@Measurement(iterations = 10)
12+
@State(Scope.Thread)
13+
public class FrameTypePerf {
14+
@Benchmark
15+
public void lookup(Input input) {
16+
FrameType frameType = input.frameType;
17+
boolean b =
18+
frameType.canHaveData()
19+
&& frameType.canHaveMetadata()
20+
&& frameType.isFragmentable()
21+
&& frameType.isRequestType()
22+
&& frameType.hasInitialRequestN();
23+
24+
input.bh.consume(b);
25+
}
26+
27+
@State(Scope.Benchmark)
28+
public static class Input {
29+
Blackhole bh;
30+
FrameType frameType;
31+
32+
@Setup
33+
public void setup(Blackhole bh) {
34+
this.bh = bh;
35+
this.frameType = FrameType.REQUEST_RESPONSE;
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)