Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@li-boxuan
Created December 24, 2021 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save li-boxuan/98d4dc18215e28b239c7433c8c39fb3f to your computer and use it in GitHub Desktop.
Save li-boxuan/98d4dc18215e28b239c7433c8c39fb3f to your computer and use it in GitHub Desktop.
@BenchmarkMode(Mode.AverageTime)
@Fork(1)
@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class MgmtOlapJobBenchmark {
@Param({"10000", "100000"})
int size;
JanusGraph graph;
public WriteConfiguration getConfiguration() {
ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
config.set(GraphDatabaseConfiguration.STORAGE_BACKEND, "inmemory");
return config.getConfiguration();
}
@Setup
public void setUp() throws Exception {
graph = JanusGraphFactory.open(getConfiguration());
JanusGraphManagement mgmt = graph.openManagement();
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex("nameIndex", Vertex.class).addKey(name).buildCompositeIndex();
mgmt.commit();
final int batchSize = Math.min(10000, size);
for (int i = 0; i < size / batchSize; i++) {
for (int j = 0; j < batchSize; j++) {
graph.addVertex("name", "value" + j, "alias", "value" + j);
}
graph.tx().commit();
}
mgmt = graph.openManagement();
mgmt.buildIndex("aliasIndex", Vertex.class).addKey(mgmt.getPropertyKey("alias")).buildCompositeIndex();
mgmt.commit();
ManagementSystem.awaitGraphIndexStatus(graph, "aliasIndex").call();
}
@org.openjdk.jmh.annotations.Benchmark
public void runReindex(Blackhole blackhole) throws ExecutionException, InterruptedException {
JanusGraphManagement mgmt = graph.openManagement();
blackhole.consume(mgmt.updateIndex(mgmt.getGraphIndex("aliasIndex"), SchemaAction.REINDEX).get());
}
@TearDown
public void tearDown() {
graph.close();
}
public static void main(String[] args) throws RunnerException {
Options options = new OptionsBuilder()
.include(MgmtOlapJobBenchmark.class.getSimpleName())
.warmupIterations(3)
.measurementIterations(5)
.build();
new Runner(options).run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment