use of org.openjdk.jmh.infra.Blackhole in project isopov-jmh by isopov.
the class ConcurrentMapBenchmark method doWork.
private void doWork(Blackhole bh, ConcurrentMap<Integer, Integer> map) throws InterruptedException {
ExecutorService pool = Executors.newFixedThreadPool(NUMBER_OF_THREADS);
for (int i = 0; i < NUMBER_OF_TASKS; i++) {
final int j = i;
pool.execute(() -> {
bh.consume(map.computeIfAbsent(tasks.get(j), val -> {
Blackhole.consumeCPU(cpu);
return val;
}));
});
}
pool.shutdown();
pool.awaitTermination(1, TimeUnit.SECONDS);
}
use of org.openjdk.jmh.infra.Blackhole in project druid by druid-io.
the class ExpressionSelectorBenchmark method timeFloorUsingExtractionFn.
@Benchmark
public void timeFloorUsingExtractionFn(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final DimensionSelector selector = cursor.getColumnSelectorFactory().makeDimensionSelector(new ExtractionDimensionSpec(ColumnHolder.TIME_COLUMN_NAME, "v", new TimeFormatExtractionFn(null, null, null, Granularities.HOUR, true)));
consumeDimension(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
use of org.openjdk.jmh.infra.Blackhole in project druid by druid-io.
the class ExpressionSelectorBenchmark method strlenUsingExpressionAsLong.
@Benchmark
public void strlenUsingExpressionAsLong(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "strlen(s)", ColumnType.STRING, TestExprMacroTable.INSTANCE))), Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("v");
consumeLong(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
use of org.openjdk.jmh.infra.Blackhole in project druid by druid-io.
the class ExpressionSelectorBenchmark method stringConcatAndCompareOnLong.
@Benchmark
public void stringConcatAndCompareOnLong(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("v", "concat(n, ' is my favorite number') == '3 is my favorite number'", ColumnType.LONG, TestExprMacroTable.INSTANCE))), Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final ColumnValueSelector selector = cursor.getColumnSelectorFactory().makeColumnValueSelector("v");
consumeLong(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
use of org.openjdk.jmh.infra.Blackhole in project druid by druid-io.
the class ExpressionSelectorBenchmark method strlenUsingExtractionFn.
@Benchmark
public void strlenUsingExtractionFn(Blackhole blackhole) {
final Sequence<Cursor> cursors = new QueryableIndexStorageAdapter(index).makeCursors(null, index.getDataInterval(), VirtualColumns.EMPTY, Granularities.ALL, false, null);
final List<?> results = cursors.map(cursor -> {
final DimensionSelector selector = cursor.getColumnSelectorFactory().makeDimensionSelector(new ExtractionDimensionSpec("x", "v", StrlenExtractionFn.instance()));
consumeDimension(cursor, selector, blackhole);
return null;
}).toList();
blackhole.consume(results);
}
Aggregations