org.openjdk.jmh.annotations.BenchmarkMode Java Examples
The following examples show how to use
org.openjdk.jmh.annotations.BenchmarkMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpTraceContextExtractBenchmark.java From opentelemetry-java with Apache License 2.0 | 6 votes |
/** Benchmark for measuring HttpTraceContext extract. */ @Benchmark @BenchmarkMode({Mode.AverageTime}) @Fork(1) @Measurement(iterations = 15, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1) @OperationsPerInvocation(COUNT) @Nullable public Context measureExtract() { Context result = null; for (int i = 0; i < COUNT; i++) { result = httpTraceContext.extract(Context.ROOT, carriers.get(i), getter); } return result; }
Example #2
Source File: HeadersBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public void http2Get(Blackhole bh) { for (AsciiString name : http2Names) { bh.consume(http2Headers.get(name)); } }
Example #3
Source File: MethodHandleGeneratorBenchmark.java From perfmark with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public long getAndSetAndGetGeneration() { long oldGeneration = generator.getGeneration(); generator.setGeneration(oldGeneration + 1); return generator.getGeneration(); }
Example #4
Source File: CallOptionsBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Adding custom call options, overwritting existing keys. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public CallOptions withOptionDuplicates() { CallOptions opts = allOpts; for (int i = 1; i < shuffledCustomOptions.size(); i++) { opts = opts.withOption(shuffledCustomOptions.get(i), "value2"); } return opts; }
Example #5
Source File: HpackDecoderULE128Benchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public int decodeMaxInt() throws Http2Exception { int v = decodeULE128(intMaxBuf, 0); intMaxBuf.readerIndex(0); return v; }
Example #6
Source File: InboundHeadersBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Checkstyle. */ @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void grpcHeaders_serverHandler(Blackhole bh) { serverHandler(bh, new GrpcHttp2RequestHeaders(4)); }
Example #7
Source File: DefaultTracerBenchmarks.java From opentelemetry-java with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode({Mode.AverageTime}) @Fork(1) @Measurement(iterations = 15, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1) public void measureGetCurrentSpan() { tracer.getCurrentSpan(); }
Example #8
Source File: StatusBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Javadoc comment. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public String messageDecodePlain() { return Status.MESSAGE_KEY.parseBytes( "Unexpected RST in stream".getBytes(Charset.forName("US-ASCII"))); }
Example #9
Source File: ReadOnlyHttp2HeadersBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public int defaultTrailers() { Http2Headers headers = new DefaultHttp2Headers(false); for (int i = 0; i < headerCount; ++i) { headers.add(headerNames[i], headerValues[i]); } return iterate(headers); }
Example #10
Source File: StatusBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** * Javadoc comment. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Status codeDecode() { return Status.CODE_KEY.parseBytes("15".getBytes(Charset.forName("US-ASCII"))); }
Example #11
Source File: SymSpellSearchBenchMark.java From customized-symspell with MIT License | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS) @Measurement(iterations = 1) public void searchBenchmark() throws SpellCheckException { for (String query : queries) { totalMatches += spellChecker.lookup(query, Verbosity.valueOf(verbosity), maxEditDistance) .size(); } }
Example #12
Source File: RawKVPutBenchmark.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.All) @OutputTimeUnit(TimeUnit.MILLISECONDS) public void put() { ThreadLocalRandom random = ThreadLocalRandom.current(); byte[] key = BytesUtil.writeUtf8("benchmark_" + random.nextInt(KEY_COUNT)); super.kvStore.put(key, VALUE_BYTES, null); }
Example #13
Source File: HttpTraceContextInjectBenchmark.java From opentelemetry-java with Apache License 2.0 | 5 votes |
/** Benchmark for measuring inject with default trace state and sampled trace options. */ @Benchmark @BenchmarkMode({Mode.AverageTime}) @Fork(1) @Measurement(iterations = 15, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1) @OperationsPerInvocation(COUNT) public Map<String, String> measureInject() { for (int i = 0; i < COUNT; i++) { httpTraceContext.inject(contexts.get(i), carrier, setter); } return carrier; }
Example #14
Source File: RheaKVPutBenchmark.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.All) @OutputTimeUnit(TimeUnit.MILLISECONDS) public void put() { ThreadLocalRandom random = ThreadLocalRandom.current(); byte[] key = BytesUtil.writeUtf8("benchmark_" + random.nextInt(KEY_COUNT)); this.kvStore.bPut(key, VALUE_BYTES); }
Example #15
Source File: VarIntsBenchmark.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.All) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void int64() { byte[] bytes = new byte[8]; putLong(bytes, 0, SMALL_VAL); getLong(bytes, 0); }
Example #16
Source File: HeadersBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public DefaultHttpHeaders httpPut() { DefaultHttpHeaders headers = new DefaultHttpHeaders(false); for (int i = 0; i < httpNames.length; i++) { headers.add(httpNames[i], httpValues[i]); } return headers; }
Example #17
Source File: WriteBenchmark.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
/** Perform the write operation. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Context doWrite(ContextState state, Blackhole bh) { return state.context.withValues( state.key1, state.val, state.key2, state.val, state.key3, state.val, state.key4, state.val); }
Example #18
Source File: AsciiCodecBenchmark.java From sofa-jraft with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void fastpathEncode() { // fast ptah AsciiStringUtil.unsafeEncode(PEER_STR); }
Example #19
Source File: HpackEncoderBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public void encode(Blackhole bh) throws Exception { HpackEncoder hpackEncoder = HpackUtilBenchmark.newTestEncoder(); output.clear(); hpackEncoder.encodeHeaders(3 /*randomly chosen*/, output, http2Headers, sensitivityDetector); bh.consume(output); }
Example #20
Source File: Utf8CodecBenchmark.java From sofa-jraft with Apache License 2.0 | 5 votes |
@SuppressWarnings("all") @Benchmark @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.MILLISECONDS) public void defaultToUtf8Bytes() { Utils.getBytes(str); }
Example #21
Source File: DefaultTracerBenchmarks.java From opentelemetry-java with Apache License 2.0 | 5 votes |
/** Benchmark just the scope lifecycle. */ @Benchmark @BenchmarkMode({Mode.AverageTime}) @Fork(1) @Measurement(iterations = 15, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1) public void measureScopeLifecycle() { try (io.opentelemetry.context.Scope ignored = tracer.withSpan(span)) { // no-op } }
Example #22
Source File: CompressionUtilsBenchmark.java From mantis with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 50, time = 3, timeUnit = TimeUnit.SECONDS) @Threads(1) public void testSnappyCompress(Blackhole blackhole, MyState state) throws IOException { blackhole.consume(CompressionUtils.compressAndBase64Encode(state.eventList, true)); }
Example #23
Source File: CompressionUtilsBenchmark.java From mantis with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 50, time = 3, timeUnit = TimeUnit.SECONDS) @Threads(1) public void testSnappyDeCompress(Blackhole blackhole, MyState state) throws IOException { blackhole.consume(CompressionUtils.decompressAndBase64Decode(state.snappyCompressed, true, true)); }
Example #24
Source File: CompressionUtilsBenchmark.java From mantis with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 10, time = 3, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 50, time = 3, timeUnit = TimeUnit.SECONDS) @Threads(1) public void testGzipDeCompress(Blackhole blackhole, MyState state) throws IOException { blackhole.consume(CompressionUtils.decompressAndBase64Decode(state.gzipCompressed, true)); }
Example #25
Source File: MethodHandleGeneratorBenchmark.java From perfmark with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void ifEnabled() { if (isEnabled(getGeneration())) { Blackhole.consumeCPU(1000); } }
Example #26
Source File: PropagatorContextExtractBenchmark.java From opentelemetry-java with Apache License 2.0 | 5 votes |
@Benchmark @Measurement(iterations = 15, time = 1) @Warmup(iterations = 5, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @BenchmarkMode(Mode.AverageTime) @Fork(1) public Span measureExtract() { return TracingContextUtils.getSpan(doExtract()); }
Example #27
Source File: HeadersBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) public DefaultHttp2Headers http2Put() { DefaultHttp2Headers headers = new DefaultHttp2Headers(false); for (int i = 0; i < http2Names.length; i++) { headers.add(http2Names[i], httpValues[i]); } return headers; }
Example #28
Source File: EnabledBenchmark.java From perfmark with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void attachKeyedTag_ss_localRef() { String bar = there; PerfMark.attachTag("hi", this, ignore -> bar); }
Example #29
Source File: VolatileGeneratorBenchmark.java From perfmark with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public void ifEnabled() { if (isEnabled(getGeneration())) { Blackhole.consumeCPU(1000); } }
Example #30
Source File: VolatileGeneratorBenchmark.java From perfmark with Apache License 2.0 | 5 votes |
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @GroupThreads(3) public long racyGetAndSetAndGetGeneration() { long oldGeneration = generator.getGeneration(); generator.setGeneration(oldGeneration + 1); return generator.getGeneration(); }