Skip to content

Instantly share code, notes, and snippets.

@mbroecheler
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbroecheler/1450d1f7fa5d3dc75aab to your computer and use it in GitHub Desktop.
Save mbroecheler/1450d1f7fa5d3dc75aab to your computer and use it in GitHub Desktop.
Making sure cache is faster than embedded BDB
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> mgmt = g.getManagementSystem();
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@27c04377
gremlin> id = mgmt.makePropertyKey("uid").dataType(Long.class).make()
==>uid
gremlin> mgmt.buildIndex('byUID',Vertex.class).addKey(id).buildCompositeIndex()
==>com.thinkaurelius.titan.graphdb.database.management.TitanGraphIndexWrapper@14f3c6fc
gremlin> mgmt.commit()
gremlin> for (int i=0;i<200;i++) { v = g.addVertex([uid:(int)Math.floor(i/2)])}
==>null
gremlin> g.commit()
==>null
gremlin> g.shutdown()
==>null
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> def times(c) { t = System.currentTimeMillis(); c.call(); return System.currentTimeMillis()-t;}
==>true
gremlin> def execute(g) {
for (int i=0;i<100;i++) {
c = 0;
for (Vertex v : g.getVertices('uid',i)) c++;
}
}
==>true
gremlin> times{execute(g)}
==>91
gremlin> times{execute(g)}
==>13
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>28
gremlin> times{execute(g)}
==>8
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>20
gremlin> times{execute(g)}
==>8
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>28
gremlin> times{execute(g)}
==>3
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>16
gremlin> times{execute(g)}
==>4
gremlin> g.shutdown()
==>null
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> times{execute(g)}
==>30
gremlin> times{execute(g)}
==>5
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>9
gremlin> g.shutdown()
==>null
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> times{execute(g)}
==>21
gremlin> g.shutdown()
==>null
gremlin> g = TitanFactory.open("berkeleyje:/tmp/test")
==>titangraph[berkeleyje:/tmp/test]
gremlin> times{execute(g)}
==>20
gremlin> g.commit()
==>null
gremlin> times{execute(g)}
==>11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment