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: 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 #3
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 #4
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 #5
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 #6
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 #7
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 Page<User> listUser() throws Exception {
	return super.listUser();
}
 
Example #8
Source File: FutureHolderBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void _completableFuture() {
	int requestId = sequencer.getAndIncrement();
	CompletableFuture<Response> completableFuture = new CompletableFuture<>();

	Response response = new Response();
	response.setRequestId(requestId - 1000);

	completableFuture.complete(response);
}
 
Example #9
Source File: ScalingPatternMatcherBenchmark.java    From stringbench with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 5, time=1)
@Measurement(iterations = 5, time=1)
@Fork(1)
public void benchmarkFindInFile() throws IOException {
	result = find(sample.getFile());
}
 
Example #10
Source File: FastSerializerBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void directByteBufferUser() {
	directByteBuffer.clear();
	directByteBufferOutput.setBuffer(directByteBuffer);
	kryo.writeObject(directByteBufferOutput, user);

	directByteBuffer.flip();
	directByteBufferInput.setBuffer(directByteBuffer);
	kryo.readObject(directByteBufferInput, User.class);
}
 
Example #11
Source File: BasicOperationsBenchmark.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
/** Encode a span using binary format. */
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public byte[] encodeSpanBinary(Data data) {
  return data.propagation.getBinaryFormat().toByteArray(data.spanToEncode.getContext());
}
 
Example #12
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 twoBitBulkContiguousUnalignedFast() {
  for (int startIndex = 1; startIndex < ROWS - 50; startIndex += 50) {
    _bitSet2Fast.readInt(startIndex, 50, unalignedUnpacked2Bit);
  }
}
 
Example #13
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 #14
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 #15
Source File: ManualBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void serializeUserList() throws Exception {
	listBuffer.clear();
	userPageSerializer.write(listBuffer, userPage);
}
 
Example #16
Source File: FindFirst.java    From cyclops with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(
iterations = 10
)
@Measurement(
iterations = 10
)
@Fork(1)
public void streamFindFirst(){
 Stream.of(1,2,3)
         .findFirst().get();
}
 
Example #17
Source File: ByteBufferBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void writeByteToUnsafe() {
	for (int i = 0; i < 1024; i++) {
		UnsafeUtils.unsafe().putByte(OFFSET + i, (byte) 1);
	}
}
 
Example #18
Source File: MethodInoveBenchmark.java    From j360-tools with Apache License 2.0 5 votes vote down vote up
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.AverageTime)
@Benchmark
@SneakyThrows
public void cgilib() {
    PreparedStatement preparedStatement = new PreparedStatement();
    for (int i = 0 ;i <= 10000 ; i++) {
        JdbcFastMethodInvocation actual = new JdbcFastMethodInvocation(JdbcFastMethodInvocation.build(PreparedStatement.class, PreparedStatement.class.getMethod("setObject", int.class, Object.class)), new Object[] {1, 100});
        actual.invoke(preparedStatement);
    }
}
 
Example #19
Source File: EnabledBenchmark.java    From perfmark with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void startStop() {
  PerfMark.startTask("hi", TAG);
  PerfMark.stopTask("hi", TAG);
}
 
Example #20
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 #21
Source File: StartEndSpanBenchmark.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
/**
 * This benchmark attempts to measure performance of start/end for a sampled root {@code Span}.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public Span startEndSampledRootSpan(Data data) {
  Span span = data.tracer.spanBuilder(SPAN_NAME).setSampler(Samplers.alwaysSample()).startSpan();
  span.end();
  return span;
}
 
Example #22
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 defaultSamplingRuleBenchmark(DefaultSamplingRulesState state) {
    return state.samplingStrategy.shouldTrace(state.samplingRequest).isSampled();
}
 
Example #23
Source File: ByteBufferBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void writeIntToBytes() {
	for (int i = 0; i < 1024; i += 4) {
		bytes[i] = 1;
		bytes[i + 1] = 1;
		bytes[i + 2] = 1;
		bytes[i + 3] = 1;
	}
}
 
Example #24
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;
  }
}
 
Example #25
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 #26
Source File: StatusBenchmark.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
/**
 * Javadoc comment.
 */
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public byte[] messageEncodePlain() {
  return Status.MESSAGE_KEY.toBytes("Unexpected RST in stream");
}
 
Example #27
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 #28
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 #29
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 unsafePage() {
	unsafeOutput.clear();
	kryo.writeObject(unsafeOutput, page);

	unsafeInput.setBuffer(bytes, 0, (int) unsafeOutput.total());
	kryo.readObject(unsafeInput, Page.class);
}
 
Example #30
Source File: FutureHolderBenchmark.java    From turbo-rpc with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void futureContainer2() {
	int requestId = sequencer.getAndIncrement();
	CompletableFuture<Response> completableFuture = new CompletableFuture<>();

	futureContainer2.addFuture(requestId, completableFuture);

	Response response = new Response();
	response.setRequestId(requestId - 1000);

	futureContainer2.notifyResponse(response);
}