本文整理匯總了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;
}