org.openjdk.jmh.annotations.Measurement Java Examples

The following examples show how to use org.openjdk.jmh.annotations.Measurement. 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: CompressionUtilsBenchmark.java    From mantis with Apache License 2.0 6 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 testBuiltInStringSplit(Blackhole blackhole, MyState state) throws IOException {
    BufferedReader bf = new BufferedReader(new StringReader(state.eventListStr));
    String line;
    List<String> msseList = new ArrayList<>();

    StringBuilder outStrB = new StringBuilder();
    while ((line = bf.readLine()) != null) {
        outStrB.append(line);
    }
    String[] toks = outStrB.toString().split("\\$\\$\\$");

    for (String tok : toks) {
        msseList.add(tok);
    }

    blackhole.consume(msseList);
}
 
Example #2
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 #3
Source File: BLSBenchmark.java    From teku with Apache License 2.0 6 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
public void verifySignatureBatchedParallelDoublePairing() {
  boolean res =
      BLS.batchVerify(
          keyPairs.stream()
              .map(kp -> Collections.singletonList(kp.getPublicKey()))
              .limit(sigCnt)
              .collect(Collectors.toList()),
          messages.subList(0, sigCnt),
          signatures.subList(0, sigCnt),
          true,
          true);
  if (!res) throw new IllegalStateException();
}
 
Example #4
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 #5
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 endDummySegmentBenchmark(DummyPopulatedRecorderState state) {
    state.recorder.endSegment();
}
 
Example #6
Source File: CentralizedSamplingStrategyBenchmark.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 boolean noSampleSamplingBenchmark(NoSampleSamplingRulesState state) {
    return state.samplingStrategy.shouldTrace(state.samplingRequest).isSampled();
}
 
Example #7
Source File: MeasurePadding.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 = 2)
public void cached() {
    insertPadding(paddingLen, negativeOnes, bb);
}
 
Example #8
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 #9
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 #10
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 beginEndSegmentBenchmark(RecorderState state) {
    state.recorder.beginSegment(SEGMENT_NAME);
    state.recorder.endSegment();
}
 
Example #11
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 void putExceptionSegmentBenchmark(BenchmarkState state) {
    state.parentSegment.addException(state.theException);
}
 
Example #12
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 #13
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 iterateBalances(Blackhole bh) {
  for (UnsignedLong balance : beaconState.getBalances()) {
    bh.consume(balance);
  }
}
 
Example #14
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 sortOldWay() {
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        Arrays.sort(this.array);
    }
}
 
Example #15
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 serializeFourChildSegment(SingleLevelSegmentState state) {
    return state.fourChildSegment.serialize();
}
 
Example #16
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 #17
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 endSubsegmentDummyParentBenchmark(DummyPopulatedRecorderState state) {
    state.recorder.endSubsegment();
}
 
Example #18
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 sha256of33byteArray(Blackhole bh) {
  int idx = cnt++ % data.size();
  dataArray[idx]++;
  byte[] hash = Hash.sha2_256(dataArray);
  bh.consume(hash);
}
 
Example #19
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 beginEndDummySegmentBenchmark(RecorderState state) {
    state.recorder.beginDummySegment();
    state.recorder.endSegment();
}
 
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: 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 beginEndSegmentSubsegmentBenchmark(RecorderState state) {
    state.recorder.beginSegment(SEGMENT_NAME);
    state.recorder.beginSubsegment(SUBSEGMENT_NAME);
    state.recorder.endSubsegment();
    state.recorder.endSegment();
}
 
Example #22
Source File: CascadedValidation.java    From doov with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(50)
@Warmup(iterations = 5)
@Measurement(iterations = 5)
public void testCascadedValidation(CascadedValidationState state, Blackhole blackhole) {
    DriverSetup driverSetup = new DriverSetup();
    Result result = state.rule.executeOn(driverSetup.model);
    assertThat(result.value()).isTrue();
    blackhole.consume(result);
}
 
Example #23
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 get(Blackhole blackhole, BenchmarkState state) {
    for (int i=0; i < state.bytes; ++i) {
        blackhole.consume(state.byteBuffer.get(i));
    }
}
 
Example #24
Source File: PutBenchmark.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.MILLISECONDS)
@Fork(value = 1)
@Threads(8)
@Benchmark
public void put(Blackhole blackhole,BenchmarkState state,ThreadState threadState) {
    for (int i = 0; i < threadState.numRows; ++i) {
        Map.Entry<String, String> pair = threadState.rows.get(i);
        state.oakMap.zc().put(pair.getKey(), pair.getValue());
        blackhole.consume(state.oakMap);
    }
}
 
Example #25
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 sortCurrentWay() {
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        Arrays.sort(this.array);
    }
}
 
Example #26
Source File: JMHSample_26_BatchSize.java    From jmh-playground with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Warmup(iterations = 5, batchSize = 5000)
@Measurement(iterations = 5, batchSize = 5000)
@BenchmarkMode(Mode.SingleShotTime)
public List<String> measureRight() {
    list.add(list.size() / 2, "something");
    return list;
}
 
Example #27
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 endSegmentBenchmark(SegmentNoChildRecorderState state) {
    state.recorder.endSegment();
}
 
Example #28
Source File: SpanBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Threads(value = 10)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addAttributesEventsStatusEnd_10Threads() {
  doSpanWork(span);
}
 
Example #29
Source File: SpanBenchmark.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 = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addAttributesEventsStatusEnd_05Threads() {
  doSpanWork(span);
}
 
Example #30
Source File: LongMinMaxSumCountBenchmark.java    From opentelemetry-java with Apache License 2.0 5 votes vote down vote up
@Benchmark
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Threads(value = 1)
public void aggregate_1Threads() {
  aggregator.recordLong(100);
}