Created
May 22, 2017 15:32
-
-
Save FylmTM/e16208c7bee5658c57ba6edadd23e546 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.duck | |
import java.util.concurrent.TimeUnit; | |
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import org.openjdk.jmh.runner.Runner; | |
import org.openjdk.jmh.runner.RunnerException; | |
import org.openjdk.jmh.runner.options.*; | |
import com.duck.DriverResourceIterator; | |
import com.duck.DriverResult; | |
import com.duck.DuckSetup; | |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.MILLISECONDS) | |
@Warmup(iterations = 1, time = 20, timeUnit = TimeUnit.SECONDS) | |
@Measurement(iterations = 1, time = 40, timeUnit = TimeUnit.SECONDS) | |
@Fork(1) | |
public class SomeQueryBenchmark { | |
@Benchmark | |
public int measureContainmentQuery(final Blackhole blackhole, | |
final DuckSetup duckSetup) { | |
int count = 0; | |
try (DriverResult result = duckSetup.getDatabase().execute( | |
"MATCH (n:Object)-[r:child*]->(o:Object) " | |
+ "WHERE n.id = '111' " | |
+ "RETURN o;")) { | |
final DriverResourceIterator<Object> column = result.columnAs("o"); | |
while (column.hasNext()) { | |
blackhole.consume(column.next()); | |
count++; | |
} | |
} | |
assert count > 0; | |
return count; | |
} | |
public static void main(final String[] args) throws RunnerException { | |
final Options opt = new OptionsBuilder() | |
.include(SomeQueryBenchmark.class.getSimpleName()) | |
.warmupIterations(0) | |
.measurementIterations(1) | |
.forks(1) | |
.measurementTime(TimeValue.seconds(10)) | |
.jvmArgs("-ea") | |
.build(); | |
new Runner(opt).run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment