java类org.openjdk.jmh.annotations.Benchmark的实例源码

TypedMapBenchmarks.java 文件源码 项目:swage 阅读 23 收藏 0 点赞 0 评论 0
@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);
            }
    );
}
StringToBytes.java 文件源码 项目:RegexPerf 阅读 25 收藏 0 点赞 0 评论 0
@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);
    }
}
ArrayBackedResourcePoolBenchmark.java 文件源码 项目:libcwfincore 阅读 25 收藏 0 点赞 0 评论 0
@Benchmark
public void measureAcquireAndReleaseSingleThreaded() throws Exception {
    try (Resource<Thing> thingResource = pool.get()) {
        Thing thing = thingResource.get();
        assertNotNull(thing);
        assertEquals(1, thing.getId());
    }
}
PositiveValues.java 文件源码 项目:simdbenchmarks 阅读 24 收藏 0 点赞 0 评论 0
@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;
}
JavaAsyncFutureBenchmark.java 文件源码 项目:future 阅读 23 收藏 0 点赞 0 评论 0
@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();
}
PositiveValues.java 文件源码 项目:simdbenchmarks 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
Benchmarks.java 文件源码 项目:aes-gcm-siv 阅读 38 收藏 0 点赞 0 评论 0
@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();
  }
}
Benchmarks.java 文件源码 项目:aes-gcm-siv 阅读 27 收藏 0 点赞 0 评论 0
@Benchmark
public byte[] aes_GCM_Encrypt() throws Exception {
  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.ENCRYPT_MODE, keySpec, gcmSpec);
  return cipher.doFinal(plaintext);
}
JMHSample_18_Control.java 文件源码 项目:mumu-benchmark 阅读 28 收藏 0 点赞 0 评论 0
@Benchmark
@Group("pingpong")
public void pong(Control cnt) {
    while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) {
        // this body is intentionally left blank
    }
}
OffHeapVarBitMetricStoreBuildBenchmark.java 文件源码 项目:yuvi 阅读 25 收藏 0 点赞 0 评论 0
@Benchmark
public void creationTime(Blackhole bh) {
  Map seriesMap = ((MetricsAndTagStoreImpl) ((ChunkImpl) chunkStore).getStore()).getMetricStore()
      .getSeriesMap();
  OffHeapVarBitMetricStore newStore = OffHeapVarBitMetricStore.toOffHeapStore(seriesMap, "", "");
  bh.consume(newStore);
}
PersonJMHTest.java 文件源码 项目:CodeKatas 阅读 30 收藏 0 点赞 0 评论 0
@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;
}
TwitterFutureBenchmark.java 文件源码 项目:future 阅读 23 收藏 0 点赞 0 评论 0
@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);
}
JavaSyncFutureBenchmark.java 文件源码 项目:future 阅读 87 收藏 0 点赞 0 评论 0
@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();
}
ArrayDuplicationBenchmark.java 文件源码 项目:openjdk-jdk10 阅读 20 收藏 0 点赞 0 评论 0
@Benchmark
@OperationsPerInvocation(TESTSIZE)
public Object[] cloneObjectArray() {
    int j = 0;
    for (int i = 0; i < TESTSIZE; i++) {
        dummy[j++] = arraysClone(testObjectArray[i]);
    }
    return dummy;
}
AbstractInMemoryDatastoreWriteTransactionBenchmark.java 文件源码 项目:hashsdn-controller 阅读 23 收藏 0 点赞 0 评论 0
@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();
    }
}
TimeMeasurementBenchmarks.java 文件源码 项目:reactor-ntp-clock 阅读 23 收藏 0 点赞 0 评论 0
@Benchmark
public void nanoTimeElapsed(Blackhole bh) {
  long nanoTimeEnd = System.nanoTime();
  long elapsed = nanoTimeEnd - nanoTimeStart;
  bh.consume(elapsed);
  nanoTimeStart = nanoTimeEnd;
}
Scale.java 文件源码 项目:simdbenchmarks 阅读 25 收藏 0 点赞 0 评论 0
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
@Benchmark
public int NaiveSum(IntData state) {
    int value = 0;
    int[] data = state.data1;
    for (int i = 0; i < data.length; ++i) {
        value += data[i];
    }
    return value;
}
Scale.java 文件源码 项目:simdbenchmarks 阅读 24 收藏 0 点赞 0 评论 0
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
@Benchmark
public int Scale_Int(IntData state) {
    int value = 0;
    int[] data = state.data1;
    for (int i = 0; i < data.length; ++i) {
        value += 10 * data[i];
    }
    return value;
}
PersonJMHTest.java 文件源码 项目:CodeKatas 阅读 26 收藏 0 点赞 0 评论 0
@Benchmark
public IntSummaryStatistics uniqueAgesSummaryStatisticsJDK_serial()
{
    final Set<Integer> uniqueAges =
            Person.getJDKPeople().stream()
                    .mapToInt(Person::getAge)
                    .boxed()
                    .collect(Collectors.toSet());
    IntSummaryStatistics summary = uniqueAges.stream().mapToInt(i -> i).summaryStatistics();
    return summary;
}
PersonJMHTest.java 文件源码 项目:CodeKatas 阅读 23 收藏 0 点赞 0 评论 0
@Benchmark
public SummaryStatistics<Person> combinedStatisticsECSinglePassStream_serial()
{
    SummaryStatistics<Person> summaryStatistics = new SummaryStatistics<Person>()
            .addDoubleFunction("height", Person::getHeightInInches)
            .addDoubleFunction("weight", Person::getWeightInPounds)
            .addIntFunction("age", Person::getAge);

    return Person.getECPeople().stream().collect(summaryStatistics.toCollector());
}
FasterByteComparisonBenchmark.java 文件源码 项目:faster 阅读 24 收藏 0 点赞 0 评论 0
@Benchmark
@OperationsPerInvocation(COMPARISONS_PER_INVOCATION)
public final void compareFourBytes(final Blackhole blackhole) {
    int res = 0;
    for (int i = 0; i < COMPARISONS_PER_INVOCATION; ++i) {
        res += FasterByteComparison.compare(FOUR_BYTES, MANY_BYTES);
    }
    blackhole.consume(res);
}
TwitterFutureBenchmark.java 文件源码 项目:future 阅读 22 收藏 0 点赞 0 评论 0
@Benchmark
public String mapPromiseN() throws Exception {
  Promise<String> p = new Promise<String>();
  Future<String> f = p;
  for (int i = 0; i < N.n; i++)
    f = f.map(mapF);
  p.setValue(string);
  return Await.result(f);
}
TwitterFutureBenchmark.java 文件源码 项目:future 阅读 22 收藏 0 点赞 0 评论 0
@Benchmark
public Void ensurePromiseN() throws Exception {
  Promise<Void> p = new Promise<>();
  Future<Void> f = p;
  for (int i = 0; i < N.n; i++)
    f = f.ensure(ensureF);
  p.setValue(null);
  return Await.result(f);
}
BenchmarkSIMDBlog.java 文件源码 项目:simd-blog 阅读 24 收藏 0 点赞 0 评论 0
@Benchmark
@CompilerControl(CompilerControl.Mode.DONT_INLINE) //makes looking at assembly easier
public int[] hashLoop(Context context)
{
    for (int i = 0; i < SIZE; i++) {
        context.results[i] = getHashPosition(context.values[i], 1048575);
    }
    return context.results;
}
ScalaFutureBenchmark.java 文件源码 项目:future 阅读 32 收藏 0 点赞 0 评论 0
@Benchmark
public Void ensurePromiseN() throws Exception {
  Promise<Void> p = Promise.<Void>apply();
  Future<Void> f = p.future();
  for (int i = 0; i < N.n; i++)
    f = f.transform(ensureF, ec);
  p.success(null);
  return Await.result(f, inf);
}
AbstractInMemoryDatastoreWriteTransactionBenchmark.java 文件源码 项目:hashsdn-controller 阅读 22 收藏 0 点赞 0 评论 0
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
    DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
    for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
        writeTx.write(OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
    }
    DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
    cohort.canCommit().get();
    cohort.preCommit().get();
    cohort.commit().get();
}
RunContainerRealDataBenchmarkOr.java 文件源码 项目:java_vs_c_bitmap_benchmark 阅读 23 收藏 0 点赞 0 评论 0
@Benchmark
public int pairwiseOr_RoaringWithRun(BenchmarkState benchmarkState) {
    int total = 0;
    for(int k = 0; k + 1 < benchmarkState.rc.size(); ++k)
        total += RoaringBitmap.or(benchmarkState.rc.get(k),benchmarkState.rc.get(k+1)).getCardinality();
    if(total != benchmarkState.totalor )
        throw new RuntimeException("bad pairwise or result");
    return total;
}
RunContainerRealDataBenchmarkAnd.java 文件源码 项目:java_vs_c_bitmap_benchmark 阅读 22 收藏 0 点赞 0 评论 0
@Benchmark
public int pairwiseAnd_RoaringWithRun(BenchmarkState benchmarkState) {
    int total = 0;
    for(int k = 0; k + 1 < benchmarkState.rc.size(); ++k)
        total += RoaringBitmap.and(benchmarkState.rc.get(k),benchmarkState.rc.get(k+1)).getCardinality();
    if(total != benchmarkState.totaland )
        throw new RuntimeException("bad pairwise and result");
    return total;
}
RunContainerRealDataBenchmarkAnd.java 文件源码 项目:java_vs_c_bitmap_benchmark 阅读 25 收藏 0 点赞 0 评论 0
@Benchmark
public int pairwiseAnd_EWAH32(BenchmarkState benchmarkState) {
    int total = 0;
    for(int k = 0; k + 1 < benchmarkState.ewah32.size(); ++k)
        total += benchmarkState.ewah32.get(k).and(benchmarkState.ewah32.get(k+1)).cardinality();
    if(total !=benchmarkState.totaland )
        throw new RuntimeException("bad pairwise and result");
    return total;
}
TwitterFutureBenchmark.java 文件源码 项目:future 阅读 24 收藏 0 点赞 0 评论 0
@Benchmark
public Void ensureConstN() throws Exception {
  Future<Void> f = constVoidFuture;
  for (int i = 0; i < N.n; i++)
    f = f.ensure(ensureF);
  return Await.result(f);
}


问题


面经


文章

微信
公众号

扫码关注公众号