当前位置: 首页>>代码示例>>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;未经允许,请勿转载。