package org.umlg.sqlg.test.gremlincompile;

import com.tinkerpop.gremlin.process.T;
import com.tinkerpop.gremlin.structure.Vertex;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Assert;
import org.junit.Test;
import org.umlg.sqlg.test.BaseTest;

/**
 * Date: 2015/02/01
 * Time: 11:48 AM
 */
public class TestTraversalPerformance extends BaseTest {

    @Test
    public void testSpeed() {
        this.sqlgGraph.tx().batchModeOn();
        Vertex a = this.sqlgGraph.addVertex(T.label, "A");
        for (int i = 0; i < 100; i++) {
            Vertex b = this.sqlgGraph.addVertex(T.label, "B");
            a.addEdge("outB", b);
            for (int j = 0; j < 1000; j++) {
                Vertex c = this.sqlgGraph.addVertex(T.label, "C");
                b.addEdge("outC", c);
                for (int k = 0; k < 100; k++) {
                    Vertex d = this.sqlgGraph.addVertex(T.label, "D");
                    c.addEdge("outD", d);
                }
            }
            this.sqlgGraph.tx().commit();
            this.sqlgGraph.tx().batchModeOn();
            System.out.println("inserted " + i);
        }
        this.sqlgGraph.tx().commit();
        System.out.println("done inserting");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        Assert.assertEquals(10000000, a.out().out().out().count().next().intValue());
        stopWatch.stop();
        System.out.println(stopWatch.toString());
    }
}

@@ -534,16 +534,20 @@
  i %3C 100
+0000
 ; i++) %7B
@@ -677,19 +677,16 @@
 0; j %3C 1
-000
 ; j++) %7B
@@ -807,189 +807,48 @@
     
-    for (int k = 0; k %3C 100; k++) %7B%0A                    Vertex d = this.sqlgGraph.addVertex(T.label, %22D%22);%0A                    c.addEdge(%22outD%22, d);%0A                %7D%0A            %7D%0A
+%7D%0A            if (i %25 10000 == 0) %7B%0A    
     
@@ -877,32 +877,36 @@
 .tx().commit();%0A
+    
             this
@@ -940,32 +940,36 @@
 ();%0A            
+ 
+   
 System.out.print
@@ -989,16 +989,30 @@
 %22 + i);%0A
+            %7D%0A
         
@@ -1206,17 +1206,16 @@
 (1000000
-0
 , a.out(
@@ -1222,22 +1222,16 @@
 ).out().
-out().
 count().

add performance test