本文整理匯總了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);
}
}