| 30 | /** Write benchmark. */ |
| 31 | public class WriteBenchmark { |
| 32 | @State(Scope.Thread) |
| 33 | public static class ContextState { |
| 34 | @Param({"0", "10", "25", "100"}) |
| 35 | public int preexistingKeys; |
| 36 | |
| 37 | Context.Key<Object> key1 = Context.key("key1"); |
| 38 | Context.Key<Object> key2 = Context.key("key2"); |
| 39 | Context.Key<Object> key3 = Context.key("key3"); |
| 40 | Context.Key<Object> key4 = Context.key("key4"); |
| 41 | Context context; |
| 42 | Object val = new Object(); |
| 43 | |
| 44 | @Setup |
| 45 | public void setup() { |
| 46 | context = Context.ROOT; |
| 47 | for (int i = 0; i < preexistingKeys; i++) { |
| 48 | context = context.withValue(Context.key("preexisting_key" + i), val); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** Perform the write operation. */ |
| 54 | @Benchmark |