當前位置: 首頁>>代碼示例>>Java>>正文


Java Benchmark類代碼示例

本文整理匯總了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);
            }
    );
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:23,代碼來源:TypedMapBenchmarks.java

示例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);
    }
}
 
開發者ID:fbacchella,項目名稱:RegexPerf,代碼行數:25,代碼來源:StringToBytes.java

示例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());
    }
}
 
開發者ID:cloudwall,項目名稱:libcwfincore,代碼行數:9,代碼來源:ArrayBackedResourcePoolBenchmark.java

示例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;
}
 
開發者ID:richardstartin,項目名稱:simdbenchmarks,代碼行數:14,代碼來源:PositiveValues.java

示例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();
}
 
開發者ID:traneio,項目名稱:future,代碼行數:8,代碼來源:JavaAsyncFutureBenchmark.java

示例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;
}
 
開發者ID:richardstartin,項目名稱:simdbenchmarks,代碼行數:11,代碼來源:PositiveValues.java

示例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();
  }
}
 
開發者ID:codahale,項目名稱:aes-gcm-siv,代碼行數:13,代碼來源:Benchmarks.java

示例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
    }
}
 
開發者ID:mumudemo,項目名稱:mumu-benchmark,代碼行數:8,代碼來源:JMHSample_18_Control.java

示例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);
}
 
開發者ID:pinterest,項目名稱:yuvi,代碼行數:8,代碼來源:OffHeapVarBitMetricStoreBuildBenchmark.java

示例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;
}
 
開發者ID:BNYMellon,項目名稱:CodeKatas,代碼行數:11,代碼來源:PersonJMHTest.java

示例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);
}
 
開發者ID:traneio,項目名稱:future,代碼行數:8,代碼來源:TwitterFutureBenchmark.java

示例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();
}
 
開發者ID:traneio,項目名稱:future,代碼行數:8,代碼來源:JavaSyncFutureBenchmark.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:ArrayDuplicationBenchmark.java

示例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;
}
 
開發者ID:jbrisbin,項目名稱:reactor-ntp-clock,代碼行數:8,代碼來源:TimeMeasurementBenchmarks.java


注:本文中的org.openjdk.jmh.annotations.Benchmark類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。