org.openjdk.jmh.annotations.Warmup Java Examples

The following examples show how to use org.openjdk.jmh.annotations.Warmup. 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 vote down vote up
/** 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: EntitySerializerBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public String serializeFourGenerationSegment(MultiLevelSegmentState state) {
    return state.fourLevelSegment.serialize();
}
 
Example #3
Source File: HttpTraceContextInjectBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
/** 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 #4
Source File: PropagatorContextInjectBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
/** Benchmark for measuring inject with default trace state and sampled trace options. */
@Benchmark
@Measurement(iterations = 15, time = 1)
@Warmup(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@BenchmarkMode(Mode.AverageTime)
@Fork(1)
public Map<String, String> measureInject() {
  Context context =
      TracingContextUtils.withSpan(DefaultSpan.create(contextToTest), Context.current());
  doInject(context, carrier);
  return carrier;
}
 
Example #5
Source File: PropagatorContextExtractBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
@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 #6
Source File: AWSXRayRecorderBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Subsegment beginSubsegmentDummyParentBenchmark(DummyPopulatedRecorderState state) {
    return state.recorder.beginSubsegment(SUBSEGMENT_NAME);
}
 
Example #7
Source File: AWSXRayRecorderBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void endSegmentNoChildBenchmark(SegmentNoChildRecorderState state) {
    state.recorder.endSegment();
}
 
Example #8
Source File: CompressionUtilsBenchmark.java    From mantis with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: SpanPipelineBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Threads(value = 5)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void runThePipeline_05Threads() {
  doWork();
}
 
Example #10
Source File: JMHSample_26_BatchSize.java    From jmh-playground with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@BenchmarkMode(Mode.AverageTime)
public List<String> measureWrong_1() {
    list.add(list.size() / 2, "something");
    return list;
}
 
Example #11
Source File: MathFunctionBenchmark.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5)
public void mathLog(ThreadState state) {
    double[] data = state.data;
    for (int i = 0; i < data.length; i++) {
        double[] result = state.result;
        result[i] = Math.log(data[i]);
    }
}
 
Example #12
Source File: MeasureFunction.java    From headlong with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 1)
public void init_with_keccak(Blackhole blackhole) {
    blackhole.consume(Function.parse("sam(bytes,bool,uint256[])", new Keccak(256)));
}
 
Example #13
Source File: AWSXRayRecorderBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void endSubsegmentBenchmark(PopulatedRecorderState state) {
    state.recorder.endSubsegment();
}
 
Example #14
Source File: GetBenchmark.java    From Oak with Apache License 2.0 5 votes vote down vote up
@Warmup(iterations = 5)
@Measurement(iterations = 10)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Fork(value = 1)
@Threads(8)
@Benchmark
public void get(Blackhole blackhole,BenchmarkState state,ThreadState threadState) {
    String key = state.keys.get(threadState.i++ % state.numRows);
    String val = state.oakMap.get(key);
    blackhole.consume(val);
}
 
Example #15
Source File: ByteBufferBenchmark.java    From Oak with Apache License 2.0 5 votes vote down vote up
@Warmup(iterations = 1)
@Measurement(iterations = 10)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(1)
@Benchmark
public void put(Blackhole blackhole, BenchmarkState state) {
    for (int i=0; i < state.bytes; ++i) {
        state.byteBuffer.put(i, (byte) i);
    }
}
 
Example #16
Source File: MeasureKeyValuePairSort.java    From headlong with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1)
@Measurement(iterations = 5)
public void sortArraysArrayList() {
    arraysArrayList.sort(KeyValuePair.PAIR_COMPARATOR);
}
 
Example #17
Source File: MathFunctionBenchmark.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5)
public void mathSin(ThreadState state) {
    double[] data = state.data;
    for (int i = 0; i < data.length; i++) {
        double[] result = state.result;
        result[i] = Math.sin(data[i]);
    }
}
 
Example #18
Source File: EntitySerializerBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public String serializeTwoGenerationSegment(MultiLevelSegmentState state) {
    return state.twoLevelSegment.serialize();
}
 
Example #19
Source File: MeasureKeyValuePairSort.java    From headlong with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1)
@Measurement(iterations = 5)
public void sortArray() {
    Arrays.sort(array, KeyValuePair.PAIR_COMPARATOR);
}
 
Example #20
Source File: SpecBenchmarks.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
public void integerSquareRoot(Blackhole bh) {
  n = n.plus(UnsignedLong.ONE);
  bh.consume(BeaconStateUtil.integer_squareroot(n));
}
 
Example #21
Source File: BitlistBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
public void setAllBits(Blackhole bh) {
  final Bitlist target = createBitlist();
  target.setAllBits(MANY_BITS_SET);
  bh.consume(target);
}
 
Example #22
Source File: ListBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
public void incrementalHash(Blackhole bh) {
  ListViewWrite<UInt64View> l2w = l2r.createWritableCopy();
  l2w.set(12345, new UInt64View(UnsignedLong.valueOf(77777)));
  ListViewRead<UInt64View> l2r_ = l2w.commitChanges();
  l2r_.hashTreeRoot();
}
 
Example #23
Source File: BeaconStateBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
public void iterateValidatorsWithMethods(Blackhole bh) {
  for (Validator validator : beaconState.getValidators()) {
    bh.consume(validator.isSlashed());
    bh.consume(validator.getPubkey());
    bh.consume(validator.getEffective_balance());
    bh.consume(validator.getActivation_epoch());
    bh.consume(validator.getExit_epoch());
    bh.consume(validator.getWithdrawable_epoch());
  }
}
 
Example #24
Source File: NodeBenchmark.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 20)
public int valueNumberLeaf_HASHMAP_COMPUTE_IF_ABSENT(HashMapComputeIfAbsent s) {
    int result = 0;
    for (Node n : s.valueNumberableLeafNodes) {
        result += (n.getNodeClass().isLeafNode() ? 1 : 0);
    }
    return result;
}
 
Example #25
Source File: ShuffleBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 2)
@Measurement(iterations = 5)
public void shuffledListBench(Blackhole bh) {
  int[] indexes = IntStream.range(0, indexCount).toArray();
  CommitteeUtil.shuffle_list(indexes, seed);
  bh.consume(indexes);
}
 
Example #26
Source File: BLSBenchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
public void verifySignatureSimple() {
  for (int i = 0; i < sigCnt; i++) {
    boolean res = BLS.verify(keyPairs.get(i).getPublicKey(), messages.get(i), signatures.get(i));
    if (!res) throw new IllegalStateException();
  }
}
 
Example #27
Source File: SortingLongBenchmarkTestJMH.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Warmup(iterations = 20)
@Measurement(iterations = 10)
@Benchmark
public void sortNewWay() {
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        SortingLongTestJMH.sort(this.array, 0, this.array.length - 1, null, 0, 0);
    }
}
 
Example #28
Source File: SortingIntBenchmarkTestJMH.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Warmup(iterations = 20)
@Measurement(iterations = 10)
@Benchmark
public void sortNewWay() {
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        SortingIntTestJMH.sort(this.array, 0, this.array.length - 1, null, 0, 0);
    }
}
 
Example #29
Source File: EntityBenchmark.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@Fork(value=1)
@Warmup(iterations = 20)
@Measurement(iterations = 20)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Subsegment constructSubsegmentPutInSegmentBenchmark(BenchmarkState state) {
    // TODO: Find a way to create just the subsegment and not force it into the parent segment?
    return new SubsegmentImpl(state.recorder, SEGMENT_NAME, state.parentSegment);
}
 
Example #30
Source File: Sha256Benchmark.java    From teku with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
public void sha256of33bytes(Blackhole bh) {
  int idx = cnt++ % data.size();
  data.set(idx, (byte) (data.get(idx) + 1));
  Bytes32 hash = Hash.sha2_256(data);
  bh.consume(hash);
}