當前位置: 首頁>>代碼示例>>Java>>正文


Java Blackhole類代碼示例

本文整理匯總了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);
    
}
 
開發者ID:Abrasha,項目名稱:benchmark-it,代碼行數:20,代碼來源:HashMapVSLinkedHashMap.java

示例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());
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:13,代碼來源:UpdateBenchmark.java

示例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());
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:28,代碼來源:LargeSelectBenchmark.java

示例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);
}
 
開發者ID:richardstartin,項目名稱:simdbenchmarks,代碼行數:12,代碼來源:Addition.java

示例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);
    }
}
 
開發者ID:davidmoten,項目名稱:hilbert-curve,代碼行數:8,代碼來源:Benchmarks.java

示例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);
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:14,代碼來源:DeserDslJson.java

示例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);
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:11,代碼來源:SerPb.java

示例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));
    }
}
 
開發者ID:davidmoten,項目名稱:hilbert-curve,代碼行數:8,代碼來源:Benchmarks.java

示例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));
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:9,代碼來源:DeserFastjson.java

示例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);
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:11,代碼來源:DeserThrift.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:NodeBenchmark.java

示例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]);
        }
    }
}
 
開發者ID:mumudemo,項目名稱:mumu-benchmark,代碼行數:10,代碼來源:JMHSample_37_CacheAccess.java

示例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]);
        }
    }
}
 
開發者ID:mumudemo,項目名稱:mumu-benchmark,代碼行數:10,代碼來源:JMHSample_37_CacheAccess.java

示例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);
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:13,代碼來源:SerDslJson.java

示例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);
    }
}
 
開發者ID:json-iterator,項目名稱:java-benchmark,代碼行數:11,代碼來源:SerJackson.java


注:本文中的org.openjdk.jmh.infra.Blackhole類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。