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
Source File: MethodHandleGeneratorBenchmark.java    From perfmark with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ifEnabled() {
  if (isEnabled(getGeneration())) {
    Blackhole.consumeCPU(1000);
  }
}
 
Example 2
Source File: VolatileGeneratorBenchmark.java    From perfmark with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ifEnabled() {
  if (isEnabled(getGeneration())) {
    Blackhole.consumeCPU(1000);
  }
}
 
Example 3
Source File: TagsBenchmark.java    From metrics with 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 File: TagsBenchmark.java    From metrics with 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
Source File: AbstractReferenceCountedByteBufBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@GroupThreads(6)
public boolean retainReleaseContended() {
    buf.retain();
    Blackhole.consumeCPU(delay);
    return buf.release();
}
 
Example 6
Source File: LambdaOverhead.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
public static void workDirectly(int tokens) {
  Blackhole.consumeCPU(tokens);
}
 
Example 7
Source File: SignatureParserBenchmark.java    From apm-agent-java with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consumeCpu() {
    // to get a feel for the jitter of this machine (most notable in higher percentiles)
    Blackhole.consumeCPU(1);
}
 
Example 8
Source File: GarmadonSerializationBenchmark.java    From garmadon with Apache License 2.0 4 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void baseline(){ //determine the cost of Blackhole.consumeCPU(1)
    Blackhole.consumeCPU(10);
}
 
Example 9
Source File: GarmadonSerializationBenchmark.java    From garmadon with Apache License 2.0 4 votes vote down vote up
@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 10
Source File: JMHSample_21_ConsumeCPU.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consume_0008() {
    Blackhole.consumeCPU(8);
}
 
Example 11
Source File: JMHSample_21_ConsumeCPU.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consume_1024() {
    Blackhole.consumeCPU(1024);
}
 
Example 12
Source File: JMHSample_21_ConsumeCPU.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consume_0002() {
    Blackhole.consumeCPU(2);
}
 
Example 13
Source File: NoTagsBenchmark.java    From metrics with 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
Source File: NoTagsBenchmark.java    From metrics with 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 15
Source File: NoTagsBenchmark.java    From metrics with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void counterDropwizard() {
  dropwizardCounter.inc();
  Blackhole.consumeCPU(CONSUME_CPU);
}
 
Example 16
Source File: JMHSample_21_ConsumeCPU.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consume_0512() {
    Blackhole.consumeCPU(512);
}
 
Example 17
Source File: TagsBenchmark.java    From metrics with 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 18
Source File: JMHSample_21_ConsumeCPU.java    From jmh-playground with Apache License 2.0 4 votes vote down vote up
@Benchmark
public void consume_0016() {
    Blackhole.consumeCPU(16);
}
 
Example 19
Source File: TagsBenchmark.java    From metrics with 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 20
Source File: TagsBenchmark.java    From metrics with 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);
}