diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/Tester.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/Tester.java index d04edf77ff7..b9f216cc2c1 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/Tester.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/Tester.java @@ -56,10 +56,10 @@ public static void main(String[] args) { int numTimesToRepeatQuery = Integer.parseInt(args[0]); GraphTraversalSource tinkerTraversal = createAirRoutesTraversalSource(); - GraphTraversalSource txTraversal = createTxAirRoutesTraversalSource(); + GraphTraversalSource txTraversal = createAirRoutesTraversalSource(); - //runLatencyReadQuery(tinkerTraversal, numTimesToRepeatQuery); - runLatencyReadQuery(txTraversal, numTimesToRepeatQuery); + runLatencyReadQuery(tinkerTraversal, numTimesToRepeatQuery); + //runLatencyReadQuery(txTraversal, numTimesToRepeatQuery); //runThroughPutReadQuery(tinkerTraversal, numTimesToRepeatQuery); //runThroughPutReadQuery(txTraversal, numTimesToRepeatQuery); runLatencyCentralVertexDropTest(numTimesToRepeatQuery); @@ -100,8 +100,8 @@ public static GraphTraversalSource createAirRoutesTraversalSource() { return tinkerGraph.traversal(); } - - public static GraphTraversalSource createTxAirRoutesTraversalSource() { +/* + public static GraphTraversalSource createAirRoutesTraversalSource() { TinkerTransactionGraph txGraph = TinkerTransactionGraph.open(getTinkerGraphConf()); //Neo4jGraph txGraph = Neo4jGraph.open("tmpfs"); @@ -115,11 +115,11 @@ public static GraphTraversalSource createTxAirRoutesTraversalSource() { return txGraph.traversal(); } - +*/ public static void runAddDirectRouteForIndirectTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().id().toList(); Long start = System.nanoTime(); @@ -131,16 +131,11 @@ public static void runAddDirectRouteForIndirectTest(int numTimes) { .where(out().is(neq("start"))) .addE("route").to("start") .iterate(); - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " to add extra direct flights"); } @@ -150,7 +145,7 @@ public static void runReduceAirportTrafficTest(int numTimes) { for (; numTimes != 0; numTimes--) { GraphTraversalSource b = TinkerFactory.createModern().traversal(); - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); Random random = new Random(5); Long start = System.nanoTime(); @@ -159,7 +154,6 @@ public static void runReduceAirportTrafficTest(int numTimes) { for (Edge e : g.V(v.id()).outE().toList()) { if (random.nextInt(3) == 0) { g.E(e.id()).drop().iterate(); - g.tx().commit(); } } } @@ -167,11 +161,7 @@ public static void runReduceAirportTrafficTest(int numTimes) { Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " to remove overloaded routes"); } @@ -199,14 +189,9 @@ public static void runLatencySingleCommitAddTest(int numTimes) { .inVertices(vertices.subList(0, vertices.size()/2)) .outVertices(vertices.subList(vertices.size()/2, vertices.size())) .create().generate(); - g.tx().commit(); Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " to create a power law 2.5 distributed graph"); } @@ -234,36 +219,26 @@ public static void runLatencyRollbackAddTest(int numTimes) { .outVertices(vertices.subList(vertices.size()/2, vertices.size())) .create().generate(); - g.tx().rollback(); Long end = System.nanoTime(); System.out.println("It took " + (end-start)/1000000 + " to rollback a power law 2.5 distributed graph"); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + } } public static void runLatencyCentralVertexDropTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().order().by(bothE().count(), desc).id().toList(); Long start = System.nanoTime(); for (Object id : vIds) { g.V(id).drop().iterate(); - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to drop all vertices"); } @@ -271,7 +246,7 @@ public static void runLatencyCentralVertexDropTest(int numTimes) { public static void runThroughputCentralVertexDropTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().order().by(bothE().count(), desc).id().toList(); ExecutorService threadPool = Executors.newFixedThreadPool(2); @@ -281,7 +256,6 @@ public static void runThroughputCentralVertexDropTest(int numTimes) { for (Object id : vIds) { futures.add(threadPool.submit(() -> { g.V(id).drop().iterate(); - g.tx().commit(); })); } @@ -300,11 +274,7 @@ public static void runThroughputCentralVertexDropTest(int numTimes) { Long end = System.nanoTime(); System.out.println("It took " + (end-start)/1000000 + " ms to drop all vertices"); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + threadPool.shutdown(); } @@ -312,7 +282,7 @@ public static void runThroughputCentralVertexDropTest(int numTimes) { public static void runLatencyRandomVertexDropTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().order().by(id(), desc).id().toList(); Random random = new Random(5); Collections.shuffle(vIds, random); @@ -320,15 +290,10 @@ public static void runLatencyRandomVertexDropTest(int numTimes) { Long start = System.nanoTime(); for (Object id : vIds) { g.V(id).drop().iterate(); - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly drop all vertices"); } @@ -336,7 +301,7 @@ public static void runLatencyRandomVertexDropTest(int numTimes) { public static void runLatencyRandomVertexDropRollbackTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().order().by(id(), desc).id().toList(); Random random = new Random(5); Collections.shuffle(vIds, random); @@ -344,15 +309,10 @@ public static void runLatencyRandomVertexDropRollbackTest(int numTimes) { Long start = System.nanoTime(); for (Object id : vIds) { g.V(id).drop().iterate(); - g.tx().rollback(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly rollback all dropped vertices"); } @@ -360,7 +320,7 @@ public static void runLatencyRandomVertexDropRollbackTest(int numTimes) { public static void runThroughputRandomVertexDropTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vIds = g.V().id().toList(); Random random = new Random(2); Collections.shuffle(vIds, random); @@ -373,7 +333,6 @@ public static void runThroughputRandomVertexDropTest(int numTimes) { int index = i; futures.add(threadPool.submit(() -> { g.V(vIds.get(index)).drop().iterate(); - g.tx().commit(); })); } @@ -392,11 +351,7 @@ public static void runThroughputRandomVertexDropTest(int numTimes) { Long end = System.nanoTime(); System.out.println("It took " + (end-start)/1000000 + " ms to drop all vertices"); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + threadPool.shutdown(); } @@ -404,7 +359,7 @@ public static void runThroughputRandomVertexDropTest(int numTimes) { public static void runLatencyRandomEdgeDropTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List edgeIds = g.E().order().by(id(), desc).id().toList(); Random random = new Random(5); Collections.shuffle(edgeIds, random); @@ -412,16 +367,11 @@ public static void runLatencyRandomEdgeDropTest(int numTimes) { Long start = System.nanoTime(); for (Object id : edgeIds) { g.V(id).drop().iterate(); - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly drop all edges"); } @@ -429,7 +379,7 @@ public static void runLatencyRandomEdgeDropTest(int numTimes) { public static void runLatencyRandomEdgeMoveTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertexIds = g.V().id().toList(); List> edgeElements = (List) g.E().project("id", "label", "props") .by(id()).by(label()).by(propertyMap()).toList(); @@ -444,16 +394,11 @@ public static void runLatencyRandomEdgeMoveTest(int numTimes) { g.V(toVertexId).addE((String) edgeElement.get("label")).from(V(fromVertexId)).property((Map) edgeElement.get("props")); g.E(edgeElement.get("id")).drop(); - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly move all edges"); } @@ -461,7 +406,7 @@ public static void runLatencyRandomEdgeMoveTest(int numTimes) { public static void runLatencyRandomEdgeMoveRollbackTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertexIds = g.V().id().toList(); List> edgeElements = (List) g.E().project("id", "label", "props") .by(id()).by(label()).by(propertyMap()).toList(); @@ -478,20 +423,11 @@ public static void runLatencyRandomEdgeMoveRollbackTest(int numTimes) { g.V(toVertexId).addE((String) edgeElements.get(i).get("label")).from(V(fromVertexId)).property((Map) edgeElements.get(i).get("props")); g.E(edgeElements.get(i).get("id")).drop(); - if (i % 2 != 0) { - g.tx().commit(); - } else { - g.tx().rollback(); - } } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly move half of the edges."); } @@ -499,7 +435,7 @@ public static void runLatencyRandomEdgeMoveRollbackTest(int numTimes) { public static void runLatencyRandomElementPropertyUpdateTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertices = g.V().id().toList(); List edges = g.E().id().toList(); Random random = new Random(5); @@ -525,16 +461,11 @@ public static void runLatencyRandomElementPropertyUpdateTest(int numTimes) { .property(__.coalesce(__.E(eId).properties().sample(1).key(), __.constant("newprop")), "changed") .iterate(); } - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly update vertices and edges"); } @@ -544,7 +475,7 @@ public static void runLatencyRandomElementPropertyUpdateTest(int numTimes) { public static void runLatencyRandomVertexPropertyAddTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertices = g.V().id().toList(); Random random = new Random(5); Collections.shuffle(vertices, random); @@ -560,16 +491,11 @@ public static void runLatencyRandomVertexPropertyAddTest(int numTimes) { .option(Merge.onMatch, CollectionFactory.asMap("newprop", "new")) .iterate(); } - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly update vertices and edges"); } @@ -577,7 +503,7 @@ public static void runLatencyRandomVertexPropertyAddTest(int numTimes) { public static void runThroughputRandomVertexPropertyAddTest(int numTimes) { for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertices = g.V().id().toList(); Random random = new Random(5); Collections.shuffle(vertices, random); @@ -593,16 +519,11 @@ public static void runThroughputRandomVertexPropertyAddTest(int numTimes) { .option(Merge.onMatch, CollectionFactory.asMap("newprop", "new")) .iterate(); } - g.tx().commit(); } Long end = System.nanoTime(); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + System.out.println("It took " + (end-start)/1000000 + " ms to randomly update vertices and edges"); } @@ -613,7 +534,7 @@ public static void runLatencyRandomEdgePropertyUpsertTest(int numTimes) { final int numVals = vals.length; for (; numTimes != 0; numTimes--) { - GraphTraversalSource g = createTxAirRoutesTraversalSource(); + GraphTraversalSource g = createAirRoutesTraversalSource(); List vertices = g.V().id().toList(); Random random = new Random(5); @@ -624,17 +545,12 @@ public static void runLatencyRandomEdgePropertyUpsertTest(int numTimes) { .option(Merge.onCreate, CollectionFactory.asMap(vals[random.nextInt(numVals)], vals[random.nextInt(numVals)])) .option(Merge.onMatch, CollectionFactory.asMap(vals[random.nextInt(numVals)], vals[random.nextInt(numVals)])) .iterate(); - g.tx().commit(); } Long end = System.nanoTime(); System.out.println("It took " + (end-start)/1000000 + " ms to randomly update vertices and edges"); - try { - g.getGraph().close(); - } catch (Exception e) { - // Intentionally do nothing. - } + } }