本文整理汇总了Java中org.openjdk.jmh.annotations.Benchmark类的典型用法代码示例。如果您正苦于以下问题:Java Benchmark类的具体用法?Java Benchmark怎么用?Java Benchmark使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Benchmark类属于org.openjdk.jmh.annotations包,在下文中一共展示了Benchmark类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: benchmarkGuava
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public void benchmarkGuava(AppState appState, ContextState ctxState) {
TypedMap data;
if (appState.numDataEntries == 0) {
data = TypedMap.empty();
} else {
final GuavaTypedMap.Builder builder = GuavaTypedMap.Builder
.with(appState.dataKeys.get(0), ctxState.datas.get(0));
IntStream.range(1, appState.numDataEntries).forEach(
i -> {
builder.add(appState.dataKeys.get(i), ctxState.datas.get(i));
}
);
data = builder.build();
}
IntStream.range(0, ctxState.numRecordings).forEach(
i -> {
appState.sink.useData(data);
}
);
}
示例2: if
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public byte[] byCharsetEncoder_US_ASCII() {
try {
CharsetEncoder encoder = asciiencode.get();
CharBuffer buffer = charbuffergenerator.get();
buffer.clear();
buffer.append(STR);
buffer.flip();
ByteBuffer outbuffer = bytebuffergenerator.get();
outbuffer.clear();
CoderResult result = encoder.encode(buffer, outbuffer, false);
if (result.isError()) {
result.throwException();
}
byte[] b = new byte[STR.length()];
outbuffer.flip();
outbuffer.get(b);
return b;
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
示例3: measureAcquireAndReleaseSingleThreaded
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public void measureAcquireAndReleaseSingleThreaded() throws Exception {
try (Resource<Thing> thingResource = pool.get()) {
Thing thing = thingResource.get();
assertNotNull(thing);
assertEquals(1, thing.getId());
}
}
示例4: BranchyCopyAndMask
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public double[] BranchyCopyAndMask(ArrayWithNegatives state) {
double[] data = state.data;
double[] result = state.target;
System.arraycopy(data, 0, result, 0, data.length);
for (int i = 0; i < result.length; ++i) {
if (result[i] < 0D) {
result[i] = 0D;
}
}
return result;
}
示例5: mapConstN
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public String mapConstN() throws InterruptedException, ExecutionException {
CompletableFuture<String> f = constFuture;
for (int i = 0; i < N.n; i++)
f = f.thenApplyAsync(mapF);
return f.get();
}
示例6: NewArray
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public double[] NewArray(ArrayWithNegatives state) {
double[] data = state.data;
double[] result = state.target;
for (int i = 0; i < result.length; ++i) {
result[i] = Math.max(data[i], 0D);
}
return result;
}
示例7: GCMParameterSpec
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public Optional<byte[]> aes_GCM_Decrypt() throws Exception {
try {
final Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
final GCMParameterSpec gcmSpec = new GCMParameterSpec(128, nonce);
final SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec, gcmSpec);
return Optional.of(cipher.doFinal(gcmCiphertext));
} catch (BadPaddingException e) {
return Optional.empty();
}
}
示例8: pong
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
@Group("pingpong")
public void pong(Control cnt) {
while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) {
// this body is intentionally left blank
}
}
示例9: creationTime
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public void creationTime(Blackhole bh) {
Map seriesMap = ((MetricsAndTagStoreImpl) ((ChunkImpl) chunkStore).getStore()).getMetricStore()
.getSeriesMap();
OffHeapVarBitMetricStore newStore = OffHeapVarBitMetricStore.toOffHeapStore(seriesMap, "", "");
bh.consume(newStore);
}
示例10: filterECLazy_serial
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public List<Person> filterECLazy_serial()
{
List<Person> filtered = Person.getECPeople()
.asLazy()
.select(person -> person.getHeightInInches() < 150)
.select(person -> person.getHeightInInches() > 80)
.toList();
return filtered;
}
示例11: ensurePromise
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public Void ensurePromise() throws Exception {
Promise<Void> p = new Promise<Void>();
Future<Void> f = p.ensure(ensureF);
p.setValue(null);
return Await.result(f);
}
示例12: flatMapConstN
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public String flatMapConstN() throws InterruptedException, ExecutionException {
CompletableFuture<String> f = constFuture;
for (int i = 0; i < N.n; i++)
f = f.thenCompose(flatMapF);
return f.get();
}
示例13: cloneObjectArray
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
@OperationsPerInvocation(TESTSIZE)
public Object[] cloneObjectArray() {
int j = 0;
for (int i = 0; i < TESTSIZE; i++) {
dummy[j++] = arraysClone(testObjectArray[i]);
}
return dummy;
}
示例14: write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
writeTx.write(OUTER_LIST_50K_PATHS[outerListKey], OUTER_LIST_TWO_ITEM_INNER_LIST[outerListKey]);
DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
cohort.canCommit().get();
cohort.preCommit().get();
cohort.commit().get();
}
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:14,代码来源:AbstractInMemoryDatastoreWriteTransactionBenchmark.java
示例15: nanoTimeElapsed
import org.openjdk.jmh.annotations.Benchmark; //导入依赖的package包/类
@Benchmark
public void nanoTimeElapsed(Blackhole bh) {
long nanoTimeEnd = System.nanoTime();
long elapsed = nanoTimeEnd - nanoTimeStart;
bh.consume(elapsed);
nanoTimeStart = nanoTimeEnd;
}