Java 类org.openjdk.jmh.annotations.Benchmark 实例源码

项目:swage    文件:TypedMapBenchmarks.java   
@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);
            }
    );
}
项目:RegexPerf    文件:StringToBytes.java   
@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);
    }
}
项目:libcwfincore    文件:ArrayBackedResourcePoolBenchmark.java   
@Benchmark
public void measureAcquireAndReleaseSingleThreaded() throws Exception {
    try (Resource<Thing> thingResource = pool.get()) {
        Thing thing = thingResource.get();
        assertNotNull(thing);
        assertEquals(1, thing.getId());
    }
}
项目:simdbenchmarks    文件:PositiveValues.java   
@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;
}
项目:future    文件:JavaAsyncFutureBenchmark.java   
@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();
}
项目:simdbenchmarks    文件:PositiveValues.java   
@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;
}
项目:aes-gcm-siv    文件:Benchmarks.java   
@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();
  }
}
项目:aes-gcm-siv    文件:Benchmarks.java   
@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);
}
项目:mumu-benchmark    文件:JMHSample_18_Control.java   
@Benchmark
@Group("pingpong")
public void pong(Control cnt) {
    while (!cnt.stopMeasurement && !flag.compareAndSet(true, false)) {
        // this body is intentionally left blank
    }
}
项目:yuvi    文件:OffHeapVarBitMetricStoreBuildBenchmark.java   
@Benchmark
public void creationTime(Blackhole bh) {
  Map seriesMap = ((MetricsAndTagStoreImpl) ((ChunkImpl) chunkStore).getStore()).getMetricStore()
      .getSeriesMap();
  OffHeapVarBitMetricStore newStore = OffHeapVarBitMetricStore.toOffHeapStore(seriesMap, "", "");
  bh.consume(newStore);
}
项目:CodeKatas    文件:PersonJMHTest.java   
@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;
}
项目:future    文件:TwitterFutureBenchmark.java   
@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);
}
项目:future    文件:JavaSyncFutureBenchmark.java   
@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();
}
项目:openjdk-jdk10    文件:ArrayDuplicationBenchmark.java   
@Benchmark
@OperationsPerInvocation(TESTSIZE)
public Object[] cloneObjectArray() {
    int j = 0;
    for (int i = 0; i < TESTSIZE; i++) {
        dummy[j++] = arraysClone(testObjectArray[i]);
    }
    return dummy;
}
项目:hashsdn-controller    文件:AbstractInMemoryDatastoreWriteTransactionBenchmark.java   
@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();
    }
}
项目:reactor-ntp-clock    文件:TimeMeasurementBenchmarks.java   
@Benchmark
public void nanoTimeElapsed(Blackhole bh) {
  long nanoTimeEnd = System.nanoTime();
  long elapsed = nanoTimeEnd - nanoTimeStart;
  bh.consume(elapsed);
  nanoTimeStart = nanoTimeEnd;
}
项目:simdbenchmarks    文件:Scale.java   
@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;
}
项目:simdbenchmarks    文件:Scale.java   
@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;
}
项目:CodeKatas    文件:PersonJMHTest.java   
@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;
}
项目:CodeKatas    文件:PersonJMHTest.java   
@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());
}
项目:faster    文件:FasterByteComparisonBenchmark.java   
@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);
}
项目:future    文件:TwitterFutureBenchmark.java   
@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);
}
项目:future    文件:TwitterFutureBenchmark.java   
@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);
}
项目:simd-blog    文件:BenchmarkSIMDBlog.java   
@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;
}
项目:future    文件:ScalaFutureBenchmark.java   
@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);
}
项目:hashsdn-controller    文件:AbstractInMemoryDatastoreWriteTransactionBenchmark.java   
@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();
}
项目:java_vs_c_bitmap_benchmark    文件:RunContainerRealDataBenchmarkOr.java   
@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;
}
项目:java_vs_c_bitmap_benchmark    文件:RunContainerRealDataBenchmarkAnd.java   
@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;
}
项目:java_vs_c_bitmap_benchmark    文件:RunContainerRealDataBenchmarkAnd.java   
@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;
}
项目:future    文件:TwitterFutureBenchmark.java   
@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);
}
项目:future    文件:ScalaFutureBenchmark.java   
@Benchmark
public Void ensureConstN() throws Exception {
  Future<Void> f = constVoidFuture;
  for (int i = 0; i < N.n; i++)
    f.transform(ensureF, ec);
  return Await.result(f, inf);
}
项目:simd-blog    文件:BenchmarkSIMDLongBlog.java   
@Benchmark
@CompilerControl(CompilerControl.Mode.DONT_INLINE) //makes looking at assembly easier
public void increment(Context context)
{
    for (int i = 0; i < SIZE; i++) {
        context.temporary[i] = context.values[i] + 1;
    }
}
项目:mumu-benchmark    文件:JMHSample_18_Control.java   
@Benchmark
@Group("pingpong")
public void ping(Control cnt) {
    while (!cnt.stopMeasurement && !flag.compareAndSet(false, true)) {
        // this body is intentionally left blank
    }
}
项目:future    文件:JavaAsyncFutureBenchmark.java   
@Benchmark
public String mapPromise() throws InterruptedException, ExecutionException {
  CompletableFuture<String> p = new CompletableFuture<String>();
  CompletableFuture<String> f = p.thenApplyAsync(mapF);
  p.complete(string);
  return f.get();
}
项目:faster    文件:FasterByteComparisonBenchmark.java   
@Benchmark
@OperationsPerInvocation(COMPARISONS_PER_INVOCATION)
public final void compareThirtyTwoBytes(final Blackhole blackhole) {
    int res = 0;
    for (int i = 0; i < COMPARISONS_PER_INVOCATION; ++i) {
        res += FasterByteComparison.compare(THIRTY_TWO_BYTES, MANY_BYTES);
    }
    blackhole.consume(res);
}
项目:beanvalidation-benchmark    文件:RawValidationSpeedBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Fork(value = 1)
@Threads(50)
@Warmup(iterations = 20) // it seems that as there are a lot of beans it takes some time to warmup
@Measurement(iterations = 30)
public void testCascadedValidation(RawValidationSpeedState state, Blackhole bh) {
    for ( Object o : state.holder.beans ) {
        Set<ConstraintViolation<Object>> constraintViolations = state.validator.validate( o );
        bh.consume( constraintViolations );
    }
}
项目:hilbert-curve    文件:Benchmarks.java   
@Benchmark
public void roundTripSmallTimes1000LowAllocation(Blackhole b) {
    for (long i = 0; i < N; i++) {
        small.point(i, point);
        b.consume(i == small.index(point));
    }
}
项目:future    文件:TraneIOFutureBenchmark.java   
@Benchmark
public String flatMapConstN() throws CheckedFutureException {
  Future<String> f = constFuture;
  for (int i = 0; i < N.n; i++)
    f = f.flatMap(flatMapF);
  return f.get(Duration.ofMillis(Long.MAX_VALUE));
}
项目:future    文件:ScalaFutureBenchmark.java   
@Benchmark
public String flatMapConstN() throws Exception {
  Future<String> f = constFuture;
  for (int i = 0; i < N.n; i++)
    f = f.flatMap(flatMapF, ec);
  return Await.result(f, inf);
}
项目:faster-than-reflection    文件:FasterThanReflectionBenchmark.java   
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@BenchmarkMode(Mode.AverageTime)
@Benchmark
public int testFieldAccessReflectionApi(FieldAccessReflectionApiState state)
        throws IllegalArgumentException, IllegalAccessException {
    return state.intValField.getInt(state.foo);
}