下面列出了org.openjdk.jmh.annotations.Mode#SingleShotTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsDefaultBlockAndPageSizeSNAPPY(Blackhole blackhole)
throws IOException
{
read(file_1M_SNAPPY, ONE_MILLION, blackhole);
}
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1)
@Measurement(iterations = 2)
public void cached() {
insertPadding(paddingLen, negativeOnes, bb);
}
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1)
@Measurement(iterations = 2)
public void uncached() {
putN(negativeOnes ? (byte) -1 : (byte) 0, paddingLen, bb);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsBS256MPS4MUncompressed(Blackhole blackhole)
throws IOException
{
read(file_1M_BS256M_PS4M, ONE_MILLION, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsBS512MPS4MUncompressed(Blackhole blackhole)
throws IOException
{
read(file_1M_BS512M_PS4M, ONE_MILLION, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void queryJdbc() throws SQLException {
try (Connection connection = dataSource.getConnection();
PreparedStatement statement = connection.prepareStatement(
"SELECT id , name , email , birthday," +
" age, homepage, uuid FROM Person LIMIT 10000 ")) {
try (ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
resultSet.getLong(1); //id
String name = resultSet.getString(2);
String email = resultSet.getString(3);
Date birthday = resultSet.getDate(4);
Integer age = resultSet.getInt(5);
String home = resultSet.getString(6);
byte[] uuid = resultSet.getBytes(7);
Person p = new Person();
p.setName(name);
p.setEmail(email);
p.setUUID(uuid == null ? null : UUID.nameUUIDFromBytes(uuid));
p.setBirthday(birthday);
p.setHomepage(home == null ? null : new URL(home));
p.setAge(age);
}
}
} catch (MalformedURLException e) {
throw new RuntimeException();
}
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void write10MRowsSnappyWithChecksums() throws IOException {
pageChecksumDataGenerator.generateData(file_10M_CHECKSUMS_SNAPPY, 10 * ONE_MILLION, true, SNAPPY);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime, Mode.SingleShotTime})
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void measureMultiple() throws InterruptedException {
TimeUnit.MILLISECONDS.sleep(100);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsUncompressedWithVerification(Blackhole blackhole) throws IOException {
readFile(file_1M_CHECKSUMS_UNCOMPRESSED, ONE_MILLION, true, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void write10MRowsUncompressedWithChecksums() throws IOException {
pageChecksumDataGenerator.generateData(file_10M_CHECKSUMS_UNCOMPRESSED, 10 * ONE_MILLION, true, UNCOMPRESSED);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void write10MRowsGzipWithoutChecksums() throws IOException {
pageChecksumDataGenerator.generateData(file_10M_NOCHECKSUMS_GZIP, 10 * ONE_MILLION, false, GZIP);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsGzipWithVerification(Blackhole blackhole) throws IOException {
readFile(file_1M_CHECKSUMS_GZIP, ONE_MILLION, true, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsGzipWithoutVerification(Blackhole blackhole) throws IOException {
readFile(file_1M_CHECKSUMS_GZIP, ONE_MILLION, false, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read10MRowsSnappyWithVerification(Blackhole blackhole) throws IOException {
readFile(file_10M_CHECKSUMS_SNAPPY, 10 * ONE_MILLION, true, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void write1MRowsUncompressedWithChecksums() throws IOException {
pageChecksumDataGenerator.generateData(file_1M_CHECKSUMS_UNCOMPRESSED, ONE_MILLION, true, UNCOMPRESSED);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read10MRowsUncompressedWithoutVerification(Blackhole blackhole) throws IOException {
readFile(file_10M_CHECKSUMS_UNCOMPRESSED, 10 * ONE_MILLION, false, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read10MRowsUncompressedWithVerification(Blackhole blackhole) throws IOException {
readFile(file_10M_CHECKSUMS_UNCOMPRESSED, 10 * ONE_MILLION, true, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read100KRowsSnappyWithoutVerification(Blackhole blackhole) throws IOException {
readFile(file_100K_CHECKSUMS_SNAPPY, 100 * ONE_K, false, blackhole);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void write10MRowsGzipWithChecksums() throws IOException {
pageChecksumDataGenerator.generateData(file_10M_CHECKSUMS_GZIP, 10 * ONE_MILLION, true, GZIP);
}
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
public void read1MRowsSnappyWithoutVerification(Blackhole blackhole) throws IOException {
readFile(file_1M_CHECKSUMS_SNAPPY, ONE_MILLION, false, blackhole);
}