Created
December 24, 2021 06:14
-
-
Save li-boxuan/98d4dc18215e28b239c7433c8c39fb3f to your computer and use it in GitHub Desktop.
This file contains 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
@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