Java Code Examples for org.openjdk.jmh.infra.Blackhole#consumeCPU()

The following examples show how to use org.openjdk.jmh.infra.Blackhole#consumeCPU() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ifEnabled() {
  if (isEnabled(getGeneration())) {
    Blackhole.consumeCPU(1000);
  }
}
 
Example 2
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ifEnabled() {
  if (isEnabled(getGeneration())) {
    Blackhole.consumeCPU(1000);
  }
}
 
Example 3
Source Project: metrics   File: TagsBenchmark.java    License: Apache License 2.0 5 votes vote down vote up
@Benchmark
public void counterDropwizard() {
  final com.codahale.metrics.Counter counter =
      dropwizardRegistry
          .counter(DROPWIZARD_COUNTER_TAGNAME_PREFIX + String.valueOf(tagValue++ % cardinality));
  counter.inc();
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 4
Source Project: metrics   File: TagsBenchmark.java    License: Apache License 2.0 5 votes vote down vote up
@Benchmark
public void gaugeDropwizard() {
  final com.codahale.metrics.Histogram histogram =
      dropwizardRegistry
          .histogram(DROPWIZARD_GAUGE_TAGNAME_PREFIX + String.valueOf(tagValue++ % cardinality));

  histogram.update(value++ % 100L);
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 5
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@GroupThreads(6)
public boolean retainReleaseContended() {
    buf.retain();
    Blackhole.consumeCPU(delay);
    return buf.release();
}
 
Example 6
Source Project: metrics   File: TagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void counterUltrabrew() {
  ultrabrewCounter.inc(TAGNAME, String.valueOf(tagValue++ % cardinality));
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 7
Source Project: metrics   File: TagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void timerUltrabrew() {
  final long startTime = ultrabrewTimer.start();
  Blackhole.consumeCPU(CONSUME_CPU);
  ultrabrewTimer.stop(startTime, TAGNAME, String.valueOf(tagValue++ % cardinality));
}
 
Example 8
@Benchmark
public void consume_0016() {
    Blackhole.consumeCPU(16);
}
 
Example 9
Source Project: metrics   File: TagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void gaugeUltrabrew() {
  ultrabrewGauge.set(value++ % 100L, TAGNAME, String.valueOf(tagValue++ % cardinality));
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 10
@Benchmark
public void consume_0512() {
    Blackhole.consumeCPU(512);
}
 
Example 11
Source Project: metrics   File: NoTagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void counterDropwizard() {
  dropwizardCounter.inc();
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 12
Source Project: metrics   File: NoTagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void timerUltrabrew() {
  final long startTime = ultrabrewTimer.start();
  Blackhole.consumeCPU(CONSUME_CPU);
  ultrabrewTimer.stop(startTime);
}
 
Example 13
Source Project: metrics   File: NoTagsBenchmark.java    License: Apache License 2.0 4 votes vote down vote up
@Benchmark
public void timerDropwizard() {
  final com.codahale.metrics.Timer.Context context = dropwizardTimer.time();
  Blackhole.consumeCPU(CONSUME_CPU);
  context.stop();
}
 
Example 14
@Benchmark
public void consume_0002() {
    Blackhole.consumeCPU(2);
}
 
Example 15
@Benchmark
public void consume_1024() {
    Blackhole.consumeCPU(1024);
}
 
Example 16
@Benchmark
public void consume_0008() {
    Blackhole.consumeCPU(8);
}
 
Example 17
@Setup
public void setUp() throws NoSuchFieldException, IllegalAccessException {
    queue = new ArrayBlockingQueue<>(queueSize);
    asyncEventProcessor = new AsyncEventProcessor(bytes -> Blackhole.consumeCPU(10));//consume some CPU to prevent any optim
}
 
Example 18
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void baseline(){ //determine the cost of Blackhole.consumeCPU(1)
    Blackhole.consumeCPU(10);
}
 
Example 19
@Benchmark
public void consumeCpu() {
    // to get a feel for the jitter of this machine (most notable in higher percentiles)
    Blackhole.consumeCPU(1);
}
 
Example 20
Source Project: jmh-playground   File: LambdaOverhead.java    License: Apache License 2.0 4 votes vote down vote up
public static void workDirectly(int tokens) {
  Blackhole.consumeCPU(tokens);
}