本文整理汇总了Java中org.openjdk.jmh.infra.Blackhole类的典型用法代码示例。如果您正苦于以下问题:Java Blackhole类的具体用法?Java Blackhole怎么用?Java Blackhole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Blackhole类属于org.openjdk.jmh.infra包,在下文中一共展示了Blackhole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linkedHashMap
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void linkedHashMap(Blackhole bh) {
Map<Integer, String> map = new LinkedHashMap<>();
map.put(0, "zero");
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
map.put(4, "four");
map.put(5, "five");
map.put(6, "six");
map.put(7, "seven");
map.put(8, "eight");
map.put(9, "nine");
bh.consume(map);
}
示例2: poolPreparedBatchUpdate
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void poolPreparedBatchUpdate(Blackhole blackhole) throws Exception {
CompletableFuture<PgResult<Row>> latch = new CompletableFuture<>();
pool.preparedBatch("UPDATE world SET randomnumber=$1 WHERE id=$2", batch, ar -> {
if (ar.succeeded()) {
latch.complete(ar.result());
} else {
latch.completeExceptionally(ar.cause());
}
});
blackhole.consume(latch.get());
}
示例3: pooledConnectionPreparedStatementQuery
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void pooledConnectionPreparedStatementQuery(Blackhole blackhole) throws Exception {
CompletableFuture<PgResult> latch = new CompletableFuture<>();
pool.getConnection(ar1 -> {
if (ar1.succeeded()) {
PgConnection conn = ar1.result();
conn.prepare("SELECT id, randomnumber from WORLD", ar2 -> {
if (ar2.succeeded()) {
PgPreparedQuery ps = ar2.result();
ps.execute(ar3 -> {
conn.close();
if (ar3.succeeded()) {
latch.complete(ar3.result());
} else {
latch.completeExceptionally(ar3.cause());
}
});
} else {
latch.completeExceptionally(ar2.cause());
}
});
} else {
latch.completeExceptionally(ar1.cause());
}
});
blackhole.consume(latch.get());
}
示例4: Add_Ints
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void Add_Ints(IntData d, Blackhole bh) {
int[] data1 = d.data1;
int[] data2 = d.data2;
int[] result = new int[data1.length];
for (int i = 0; i < data1.length; ++i) {
result[i] = data1[i] + data2[i];
}
bh.consume(result);
}
示例5: pointSmallTimes1000LowAllocation
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void pointSmallTimes1000LowAllocation(Blackhole b) {
for (long i = 0; i < N; i++) {
small.point(i, point);
b.consume(point);
}
}
示例6: deser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws IOException {
for (int i = 0; i < 1000; i++) {
reader.reset();
reader.read();
reader.getNextToken();
TestObject obj = new TestObject();
ExternalSerialization.deserialize(obj, reader);
bh.consume(obj);
}
}
示例7: ser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
for (int i = 0; i < 1000; i++) {
byteArrayOutputStream.reset();
testObject.writeTo(byteArrayOutputStream);
bh.consume(byteArrayOutputStream);
}
}
示例8: roundTripSmallTimes1000LowAllocation
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void roundTripSmallTimes1000LowAllocation(Blackhole b) {
for (long i = 0; i < N; i++) {
small.point(i, point);
b.consume(i == small.index(point));
}
}
示例9: deser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) {
for (int i = 0; i < 1000; i++) {
bh.consume(JSON.parseObject(testJSON, TestObject.class));
}
}
示例10: deser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void deser(Blackhole bh) throws TException {
for (int i = 0; i < 1000; i++) {
ThriftTestObject obj = new ThriftTestObject();
deserializer.deserialize(testObject, testData);
bh.consume(obj);
}
}
示例11: createAndDeleteAdd
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
public void createAndDeleteAdd(StringEquals s, Blackhole bh) {
AddNode addNode = new AddNode(ConstantNode.forInt(40), ConstantNode.forInt(2));
s.graph.addOrUniqueWithInputs(addNode);
GraphUtil.killWithUnusedFloatingInputs(addNode);
bh.consume(addNode);
}
示例12: colFirst
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@OperationsPerInvocation(MATRIX_SIZE)
public void colFirst(Blackhole bh) {
for (int c = 0; c < COUNT; c++) {
for (int r = 0; r < COUNT; r++) {
bh.consume(matrix[r][c]);
}
}
}
示例13: rowFirst
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@OperationsPerInvocation(MATRIX_SIZE)
public void rowFirst(Blackhole bh) {
for (int r = 0; r < COUNT; r++) {
for (int c = 0; c < COUNT; c++) {
bh.consume(matrix[r][c]);
}
}
}
示例14: ser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
for (int i = 0; i < 1000; i++) {
jsonWriter.reset();
byteArrayOutputStream.reset();
ExternalSerialization.serialize(testObject, jsonWriter, false);
jsonWriter.toStream(byteArrayOutputStream);
bh.consume(byteArrayOutputStream);
}
}
示例15: ser
import org.openjdk.jmh.infra.Blackhole; //导入依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
for (int i = 0; i < 1000; i++) {
byteArrayOutputStream.reset();
objectMapper.writeValue(byteArrayOutputStream, testObject);
bh.consume(byteArrayOutputStream);
}
}