org.openjdk.jmh.annotations.Mode Java Examples

The following examples show how to use org.openjdk.jmh.annotations.Mode. 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: BenchmarkFixedIntArrayOffHeapIdMap.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public IdMap<FixedIntArray> benchmarkOffHeapPreSizeWithoutCache()
    throws IOException {
  PinotDataBufferMemoryManager memoryManager = new DirectMemoryManager("perfTest");

  IdMap<FixedIntArray> idMap =
      new FixedIntArrayOffHeapIdMap(CARDINALITY, 0, NUM_COLUMNS, memoryManager, "perfTestWithCache");

  for (FixedIntArray value : _values) {
    idMap.put(value);
  }

  memoryManager.close();
  return idMap;
}
 
Example #2
Source File: VectorOps.java    From cyclops with Apache License 2.0 6 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(
    iterations = 10
)
@Measurement(
    iterations = 10
)
@Fork(1)
public void vectorXOps() {

    vectorX.map(i -> i * 2)
            .concatMap(i->Vector.range(0,10))
            .map(i -> i * 2)
            .filter(i -> i < 5000)
            .map(i -> "hello " + i)
            .zip(Vector.range(0,1000000))
            .map(i->i._1())
            .map(i -> i.length())
           .foldLeft((a, b) -> a + b);




}
 
Example #3
Source File: ReasoningBenchmark.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void forwardChainingSchemaCachingRDFSInferencer() throws IOException {
	SailRepository sail = new SailRepository(new SchemaCachingRDFSInferencer(new MemoryStore()));

	try (SailRepositoryConnection connection = sail.getConnection()) {
		connection.begin();

		connection.add(resourceAsStream("schema.ttl"), "", RDFFormat.TURTLE);
		addAllDataSingleTransaction(connection);

		connection.commit();
	}

	checkSize(sail);
}
 
Example #4
Source File: FHIRBenchmarkRunner.java    From FHIR with Apache License 2.0 6 votes vote down vote up
/**
 * Run the benchmark with all the examples in BenchmarkUtil.SPEC_EXAMPLE_NAMES
 */
public Collection<RunResult> runAll() throws RunnerException {
    Options opt = new OptionsBuilder()
            .include(".*" + benchmarkClass.getSimpleName() + ".*")
            .jvmArgsPrepend("-Xms4g", "-Xmx4g")
            .jvmArgsAppend(properties.toArray(new String[properties.size()]))
            .verbosity(VerboseMode.NORMAL)
            .warmupIterations(1)
            .warmupTime(TimeValue.seconds(10))
            .measurementIterations(1)
            .measurementTime(TimeValue.seconds(10))
            .shouldDoGC(true)
            .forks(1)
            .output("results.txt")
            .mode(Mode.SingleShotTime)
            .param("exampleName", BenchmarkUtil.SPEC_EXAMPLE_NAMES.toArray(new String[0])) // https://stackoverflow.com/a/4042464/161022
            .build();
    return new Runner(opt).run();
}
 
Example #5
Source File: ThreadLocalBenchmark.java    From turbo-rpc with Apache License 2.0 6 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public Integer threadIdMap() {
	Long key = Thread.currentThread().getId();
	Integer value = threadIdMap.get(key);

	if (value != null) {
		return value;
	}

	value = 100;
	threadIdMap.put(key, value);

	return value;
}
 
Example #6
Source File: StringTest.java    From turbo-rpc with Apache License 2.0 6 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@SuppressWarnings("deprecation")
public byte[] getBytesAsciiWithBuffer() throws Exception {
	boolean ascii = false;
	if (isLatin1Method != null) {
		try {
			ascii = (boolean) isLatin1Method.invoke(str);
		} catch (Exception e) {
			ascii = false;
		}
	}

	if (ascii) {
		byte[] buffer = bufferHolder.get();
		str.getBytes(0, str.length(), buffer, 0);
		return buffer;
	} else {
		return str.getBytes(StandardCharsets.UTF_8);
	}
}
 
Example #7
Source File: ArrayBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public byte loopReadByteBytes() {
	byte value = 0;

	for (int i = 0; i < length; i++) {
		value = bytes[i];
	}

	return value;
}
 
Example #8
Source File: BenchmarkPinotDataBitSet.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void sixteenBitBulkContiguous() {
  for (int startIndex = 0; startIndex < ROWS; startIndex += 32) {
    _bitSet16.readInt(startIndex, 16, 32, unpacked);
  }
}
 
Example #9
Source File: InboundHeadersBenchmark.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
/**
 *  Checkstyle.
 */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void grpcHeaders_clientHandler(Blackhole bh) {
  clientHandler(bh, new GrpcHttp2ResponseHeaders(2));
}
 
Example #10
Source File: RpcClientBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Override
public Object getUser() throws Exception {
	return super.getUser();
}
 
Example #11
Source File: Client.java    From rpc-benchmark with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public MotanUser getUser() throws Exception {
	int id = counter.getAndIncrement();
	return userService.getUser(id);
}
 
Example #12
Source File: DefaultBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void nettyByteBufPage() {
	nettyByteBuf.clear();
	nettyByteBufOutput.setBuffer(nettyByteBuf);
	kryo.writeObject(nettyByteBufOutput, page);

	nettyByteBufInput.setBuffer(nettyByteBuf);
	kryo.readObject(nettyByteBufInput, Page.class);
}
 
Example #13
Source File: ReadOnlyHttp2HeadersBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public int defaultClientHeaders() {
    Http2Headers headers = new DefaultHttp2Headers(false);
    for (int i = 0; i < headerCount; ++i) {
        headers.add(headerNames[i], headerValues[i]);
    }
    headers.method(HttpMethod.POST.asciiName());
    headers.scheme(HttpScheme.HTTPS.name());
    headers.path(path);
    headers.authority(authority);
    return iterate(headers);
}
 
Example #14
Source File: JacksonBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void serializeUserList2() throws Exception {
	nioBuffer.clear();
	listBuffer.clear();

	mapper.writeValue(nioOutputStream, userPage);

	nioBuffer.flip();
	listBuffer.writeBytes(nioBuffer);
}
 
Example #15
Source File: Client.java    From rpc-benchmark with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput, Mode.AverageTime, Mode.SampleTime })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Override
public User getUser() throws Exception {
	return super.getUser();
}
 
Example #16
Source File: BenchmarkDemo.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.All)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void testTheMethod4(TestState state, Blackhole blackhole) {
    SomeClass someClass = new SomeClass();
    blackhole.consume(someClass.someMethod(state.m, state.s));
}
 
Example #17
Source File: BenchmarkTest.java    From requery with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void queryPerson() {
    try (Result<Person> results = data.select(Person.class).limit(10000).get()) {
        for (Person p : results) {
            p.getName();
        }
    }
}
 
Example #18
Source File: ArrayBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void loopSetDirectByteBuffer() {
	directByteBuffe.clear();

	for (int i = 0; i < length; i++) {
		directByteBuffe.put((byte) i);
	}
}
 
Example #19
Source File: InboundHeadersBenchmark.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@CompilerControl(CompilerControl.Mode.INLINE)
private static void clientHandler(Blackhole bh, Http2Headers headers) {
  // NettyClientHandler does not directly access headers, but convert to Metadata immediately.

  bh.consume(headers.add(responseHeaders[0], responseHeaders[1]));
  bh.consume(headers.add(responseHeaders[2], responseHeaders[3]));

  bh.consume(Utils.convertHeaders(headers));
}
 
Example #20
Source File: TraceContextImplBenchmark.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
/**
 * This benchmark attempts to measure performance of {@link TextFormat#extract(Object, Getter)}.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public SpanContext extract(Data data) throws SpanContextParseException {
  return data.textFormatBase.extract(data.spanContextHeaders);
}
 
Example #21
Source File: BenchmarkDictionaryCreation.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int benchmarkStringDictionaryCreation()
    throws IOException {
  try (SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(_sortedStrings, STRING_FIELD,
      INDEX_DIR)) {
    dictionaryCreator.build();
    return dictionaryCreator.indexOfSV("0");
  }
}
 
Example #22
Source File: JMHBenchmark.java    From btree4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws RunnerException {
    Options opt = new OptionsBuilder().include(JMHBenchmark.class.getSimpleName())
                                      .forks(1)
                                      .warmupIterations(5)
                                      .measurementIterations(10)
                                      .mode(Mode.Throughput)
                                      .build();

    new Runner(opt).run();
}
 
Example #23
Source File: HeadersBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public void http2Iterate(Blackhole bh) {
    for (Entry<CharSequence, CharSequence> entry : http2Headers) {
        bh.consume(entry);
    }
}
 
Example #24
Source File: RecordBatchedBenchmark.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
/** Record batched double last value measures. */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public MeasureMap recordBatchedDoubleLastValue(Data data) {
  MeasureMap map = data.recorder.newMeasureMap();
  for (int i = 0; i < data.numValues; i++) {
    map.put(StatsBenchmarksUtil.DOUBLE_LASTVALUE_MEASURES[i], (double) i);
  }
  map.record(data.tags);
  return map;
}
 
Example #25
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 #26
Source File: BenchmarkPinotDataBitSet.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void twoBitContiguous() {
  for (int startIndex = 0; startIndex < ROWS; startIndex++) {
    _bitSet2.readInt(startIndex, 2);
  }
}
 
Example #27
Source File: ReadOnlyHttp2HeadersBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@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 #28
Source File: StatusBenchmark.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
/**
 * Javadoc comment.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Status codeDecode() {
  return Status.CODE_KEY.parseBytes("15".getBytes(Charset.forName("US-ASCII")));
}
 
Example #29
Source File: ArrayBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void batchSetByteBuffer() {
	byteBuffe.clear();
	byteBuffe.put(bytes);
}
 
Example #30
Source File: BenchmarkDictionary.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public int benchmarkOffHeapPreSizeWithOverflow()
    throws IOException {
  try (LongOffHeapMutableDictionary dictionary = new LongOffHeapMutableDictionary(CARDINALITY, 1000, _memoryManager,
      "longColumn")) {
    int value = 0;
    for (Long colValue : _colValues) {
      value += dictionary.index(colValue);
    }
    return value;
  }
}