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

项目:mumu-rocketmq    文件:RocketMQAsyncMessage.java   
/**
 * 发送异步消息
 * @throws InterruptedException
 * @throws RemotingException
 * @throws MQClientException
 * @throws MQBrokerException
 */
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendAsyncMessage() throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
    producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC,message), new SendCallback() {
        @Override
        public void onSuccess(SendResult sendResult) {
            //System.out.println("receive message"+sendResult);
        }

        @Override
        public void onException(Throwable throwable) {
            //System.out.println("receive message error"+throwable.getLocalizedMessage());
        }
    });
}
项目:direwolves    文件:ValidationBenchmarks.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@OperationsPerInvocation(10000)
public void testApi() {
  Map<String, Object> data = new HashMap<String, Object>();
  data.put("encryptKey", "0000000000000000");
  data.put("barcode", "LH10312ACCF23C4F3A5");

  Multimap<String, Rule> rules = ArrayListMultimap.create();

  rules.put("barcode", Rule.required());
  rules.put("barcode", Rule.regex("[0-9A-F]{16}"));
  rules.put("encryptKey", Rule.required());
  rules.put("encryptKey", Rule.regex("LH[0-7][0-9a-fA-F]{2}[0-5][0-4][0-9a-fA-F]{12}"));
  try {
    Validations.validate(data, rules);
  } catch (Exception e) {
  }

}
项目:direwolves    文件:ValidationBenchmarks.java   
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(1)
@OperationsPerInvocation(10000)
public void testAverage() {
  Map<String, Object> data = new HashMap<String, Object>();
  data.put("encryptKey", "0000000000000000");
  data.put("barcode", "LH10312ACCF23C4F3A5");

  Multimap<String, Rule> rules = ArrayListMultimap.create();

  rules.put("barcode", Rule.required());
  rules.put("barcode", Rule.regex("[0-9A-F]{16}"));
  rules.put("encryptKey", Rule.required());
  rules.put("encryptKey", Rule.regex("LH[0-7][0-9a-fA-F]{2}[0-5][0-4][0-9a-fA-F]{12}"));
  try {
    Validations.validate(data, rules);
  } catch (Exception e) {
  }
}
项目:deltaforce    文件:ClientOrderBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void latency() throws InvalidObjectException {
    ClientOrderBuilder order = new ClientOrderBuilder();
    order.setClientId(1234);
    order.setAssignee("ALGO");
    order.setBoardCode("MAIN");
    order.setCurrencyCode("HKD");
    order.setQuantity(1000);
    order.setId(123456789);
    order.setPrice(3.0);
    order.setCreatedBy("CREATEDBY");
    order.setUpdatedBy("UPDATEDBY");
    order.setExchangeCode("1234");
    order.setFixOrder(true);
    order.setCreatedTime(System.currentTimeMillis());
    order.setOrderStatus((byte) 'a');
    order.setSide((byte) '1');

    order.apply();
    orders[(index++) % orders.length] = order;
}
项目:benchmarks    文件:ReentrantLockBenchmark.java   
@Benchmark
@BenchmarkMode({   Mode.Throughput})
  @OutputTimeUnit
    (TimeUnit.MILLISECONDS)
public long testUnfairLockContended(Contended contended )
{
    contended.unfairLock.lock();
    try{
        return execute();
    }
    finally
    {
        contended.unfairLock.unlock();
    }



}
项目:benchmarks    文件:ReentrantLockBenchmark.java   
@Benchmark
@BenchmarkMode({   Mode.Throughput})
  @OutputTimeUnit
    (TimeUnit.MILLISECONDS)
public long testFairLockContended(Contended contended)
{
    contended.fairLock.lock();
    try{
        return execute();
    }
    finally
    {
        contended.fairLock.unlock();
    }



}
项目:incubator-pirk    文件:PaillierBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testWithGMP(PaillierBenchmarkState allState)
{
  SystemConfiguration.setProperty("paillier.useGMPForModPow", "true");
  SystemConfiguration.setProperty("paillier.GMPConstantTimeMode", "false");
  ModPowAbstraction.reloadConfiguration();

  try
  {
    allState.pallier.encrypt(allState.m1, allState.r1);
  } catch (PIRException e)
  {
    logger.info("Exception in testWithGMP!\n");
  }
}
项目:incubator-pirk    文件:PaillierBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testWithGMPConstantTime(PaillierBenchmarkState allState)
{
  SystemConfiguration.setProperty("paillier.useGMPForModPow", "true");
  SystemConfiguration.setProperty("paillier.GMPConstantTimeMode", "true");
  ModPowAbstraction.reloadConfiguration();

  try
  {
    allState.pallier.encrypt(allState.m1, allState.r1);
  } catch (PIRException e)
  {
    logger.info("Exception in testWithGMPConstantTime!\n");
  }
}
项目:tchannel-java    文件:PingPongMultiServerBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void benchmark(final AdditionalCounters counters) throws Exception {
    JsonRequest<Ping> request = new JsonRequest.Builder<Ping>("ping-server", "ping")
        .setBody(new Ping("ping?"))
        .setTimeout(20000)
        .setRetryLimit(0)
        .build();

    TFuture<JsonResponse<Pong>> future = this.subClient.send(request);
    future.addCallback(new TFutureCallback<JsonResponse<Pong>>() {
        @Override
        public void onResponse(JsonResponse<Pong> pongResponse) {
            if (!pongResponse.isError()) {
                counters.actualQPS.incrementAndGet();
            } else {
                counters.errorQPS.incrementAndGet();
            }
        }
    });
}
项目:protobuf-el    文件:BuilderBenchmark.java   
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime})
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Measurement(iterations = ITERATIONS_COUNT, time = 1000, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public Message timeMergeAndBuild() {
  dummy = ++dummy % Integer.MAX_VALUE;

  Builder builder = newBuilder(expectedMessage)
      .getFieldBuilder(galaxyStar, 0)
          .setField(starName, String.valueOf(dummy))
          .mergeFrom(mergeStar1Message)
          .getFieldBuilder(starPlanet, 0)
              .mergeFrom(mergePlanet1Message)
              .toParent()
          .toParent();

  return builder.build();
}
项目:jmh    文件:BenchmarkGenerator.java   
private void generateImport(PrintWriter writer) {
    Class<?>[] imports = new Class<?>[]{
            List.class, AtomicInteger.class,
            Collection.class, ArrayList.class,
            TimeUnit.class, Generated.class, CompilerControl.class,
            InfraControl.class, ThreadParams.class,
            Result.class, ThroughputResult.class, AverageTimeResult.class,
            SampleTimeResult.class, SingleShotResult.class, SampleBuffer.class,
            Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class,
            BenchmarkMode.class, RawResults.class, ResultRole.class,
            Field.class, BenchmarkParams.class, IterationParams.class
    };

    for (Class<?> c : imports) {
        writer.println("import " + c.getName() + ';');
    }
    writer.println();
}
项目:mumu-rocketmq    文件:RocketMQSyncMessage.java   
/**
 * 发送同步消息
 * @throws InterruptedException
 * @throws RemotingException
 * @throws MQClientException
 * @throws MQBrokerException
 */
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendMessage(){
    try {
        SendResult sendResult = producer.send(new Message(RocketMQConfiguration.ROCKETMQ_TOPIC, message));
    } catch (Exception e) {
        //e.printStackTrace();
    }
}
项目:mumu-benchmark    文件:JMHSample_26_BatchSize.java   
@Benchmark
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@BenchmarkMode(Mode.AverageTime)
public List<String> measureWrong_1() {
    list.add(list.size() / 2, "something");
    return list;
}
项目:mumu-benchmark    文件:JMHSample_26_BatchSize.java   
@Benchmark
@Warmup(iterations = 5, time = 5)
@Measurement(iterations = 5, time = 5)
@BenchmarkMode(Mode.AverageTime)
public List<String> measureWrong_5() {
    list.add(list.size() / 2, "something");
    return list;
}
项目:mumu-benchmark    文件:JMHSample_26_BatchSize.java   
@Benchmark
@Warmup(iterations = 5, batchSize = 5000)
@Measurement(iterations = 5, batchSize = 5000)
@BenchmarkMode(Mode.SingleShotTime)
public List<String> measureRight() {
    list.add(list.size() / 2, "something");
    return list;
}
项目:beanvalidation-benchmark    文件:ParsingBeansSpeedBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(value = 1)
@Threads(1)
@Warmup(iterations = 5)
@Measurement(iterations = 20)
public void testCascadedValidation(ParsingBeansSpeedState state, Blackhole bh) {
    // Validator in new factory

    for ( Object o : state.holder.beans ) {
        bh.consume( state.validator.getConstraintsForClass( o.getClass() ).isBeanConstrained() );
    }
}
项目: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 );
    }
}
项目:mumu-zbus    文件:ZbusProcedureBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void sendMessage(){
    try {
        Message msg = new Message(new String(MESSAGE_BYTES));
        //msg.setTopic(ZbusConfiguration.topicName);
        Message message = producer.sendSync(msg);
        //producer.sendAsync(msg);
    }catch (Exception e){
        e.printStackTrace();
    }
}
项目: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);
}
项目:faster-than-reflection    文件:FasterThanReflectionBenchmark.java   
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@BenchmarkMode(Mode.AverageTime)
@Benchmark
public int testPropertyAccessReflectionApi(PropertyAccessReflectionApiState state)
        throws IllegalAccessException, InvocationTargetException {
    return (int)state.intValAccessorMethod.invoke(state.foo);
}
项目:preDict    文件:LuceneBenchmark.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public List<String> testSingleSearch(Data data, Iterator i) {
    String query = null;
    while(query == null) {
        query = i.getNextQuery(data.queries);
    }
    return data.wordSearch.findSimilarWords(query);
}
项目:prometheus-client    文件:SummaryThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientSummaryThroughput() {
  promSummary = io.prometheus.client.Summary.build().name("name").help("help").create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promSummary.observe(i);
  }
}
项目:prometheus-client    文件:SummaryThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientSummaryThroughputWithLabels() {
  promSummary = io.prometheus.client.Summary.build().name("name").help("help").labelNames(LABEL_NAMES).create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promSummary.labels(LABEL_VALUES.get(i % LABEL_VALUES.size())).observe(i);
  }
}
项目:prometheus-client    文件:SummaryThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSummaryThroughput() {
  summary = new SummaryBuilder("name", "help").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    summary.observe(i);
  }
}
项目:prometheus-client    文件:SummaryThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSummaryThroughputWithLabels() {
  summary = new SummaryBuilder("name", "help").withReservoir().withUniformReservoir(1000).withLabels("label1", "label2").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    summary.observe(i, LABEL_VALUES.get(i % LABEL_VALUES.size()));
  }
}
项目:prometheus-client    文件:SettableGaugeLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeLatency() {
  promGauge = io.prometheus.client.Gauge.build().name("name").help("help").create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promGauge.inc();
  }
  actualIterations = promGauge.labels().get();
}
项目:prometheus-client    文件:SettableGaugeLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeLatencyWithLabels() {
  promGauge = io.prometheus.client.Gauge.build().name("name").help("help").labelNames(LABEL_NAMES).create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promGauge.labels(LABEL_VALUES).inc();
  }
  actualIterations = promGauge.labels(LABEL_VALUES).get();
}
项目:prometheus-client    文件:SettableGaugeLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeLatency() {
  gauge = new SettableGaugeBuilder("name", "help").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    gauge.set(i);
  }
  actualIterations = gauge.getValue() + 1;
}
项目:prometheus-client    文件:SettableGaugeLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeLatencyWithLabels() {
  gauge = new SettableGaugeBuilder("name", "help").withLabels("label1", "label2").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    gauge.set(i, LABEL_VALUES);
  }
  actualIterations = gauge.getValue(LABEL_VALUES) + 1;
}
项目:prometheus-client    文件:HistogramLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeLatency() {
  promHistogram = io.prometheus.client.Histogram.build().name("name").help("help").create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promHistogram.observe(i);
  }
}
项目:prometheus-client    文件:HistogramLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeLatencyWithLabels() {
  promHistogram = io.prometheus.client.Histogram.build().name("name").help("help").labelNames(LABEL_NAMES).create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promHistogram.labels(LABEL_VALUES).observe(i);
  }
}
项目:prometheus-client    文件:HistogramLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeLatency() {
  histogram = new HistogramBuilder("name", "help").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    histogram.observe(i);
  }
}
项目:prometheus-client    文件:HistogramLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeLatencyWithLabels() {
  histogram = new HistogramBuilder("name", "help").withLabels("label1", "label2").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    histogram.observe(i, LABEL_VALUES);
  }
}
项目:prometheus-client    文件:SettableGaugeThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeThroughput() {
  promGauge = io.prometheus.client.Gauge.build().name("name").help("help").create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promGauge.inc();
  }
  actualIterations = promGauge.labels().get();
}
项目:prometheus-client    文件:SettableGaugeThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientGaugeThroughputWithLabels() {
  promGauge = io.prometheus.client.Gauge.build().name("name").help("help").labelNames(LABEL_NAMES).create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promGauge.labels(LABEL_VALUES.get(i % LABEL_VALUES.size())).inc();
  }
  actualIterations = LABEL_VALUES.stream().mapToDouble(labelValues -> promGauge.labels(labelValues).get()).sum();
}
项目:prometheus-client    文件:SettableGaugeThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeThroughput() {
  gauge = new SettableGaugeBuilder("name", "help").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    gauge.set(i);
  }
  actualIterations = gauge.getValue() + 1;
}
项目:prometheus-client    文件:SettableGaugeThroughputTest.java   
@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableGaugeThroughputWithLabels() {
  gauge = new SettableGaugeBuilder("name", "help").withLabels("label1", "label2").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    gauge.set(i, LABEL_VALUES.get(i % LABEL_VALUES.size()));
  }
  actualIterations = LABEL_VALUES.stream()
    .mapToDouble(labelValues -> gauge.getValue(labelValues))
    .max()
    .orElseThrow(() -> new RuntimeException("Error")) + 1;
}
项目:prometheus-client    文件:SummaryLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientSummaryLatency() {
  promSummary = io.prometheus.client.Summary.build().name("name").help("help").create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promSummary.observe(i);
  }
}
项目:prometheus-client    文件:SummaryLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSimpleClientSummaryLatencyWithLabels() {
  promSummary = io.prometheus.client.Summary.build().name("name").help("help").labelNames(LABEL_NAMES).create();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    promSummary.labels(LABEL_VALUES).observe(i);
  }
}
项目:prometheus-client    文件:SummaryLatencyTest.java   
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void measureSettableSummaryLatency() {
  summary = new SummaryBuilder("name", "help").build();
  for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
    summary.observe(i);
  }
}