Skip to content

Instantly share code, notes, and snippets.

@robertdale
Last active August 30, 2016 12:33
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 robertdale/58d7b7efa0d4d950109a80281e11a65f to your computer and use it in GitHub Desktop.
Save robertdale/58d7b7efa0d4d950109a80281e11a65f to your computer and use it in GitHub Desktop.
// set this to your server gremlin pool
cores = 8
cluster = Cluster.open('conf/remote.yaml');
client = cluster.connect();
client.submit("graph.createIndex('name',Vertex.class)").all().get()
// NEO4J
//client.submit("graph.cypher('CREATE INDEX ON :production_part(name)')").all().get()
params = new HashMap();
start = System.currentTimeMillis()
total = System.currentTimeMillis()
for (p = 0; p <800000; p++) {
params.put('pn', 'part'+p)
rs = client.submit("g.addV('production_part').property('name',pn).iterate()", params).all()
// sync
if ( p % cores == 0) rs.get()
if (p % 10000 == 0) {
elapsed = (System.currentTimeMillis() - start) / 1000.0
println '' + p + ' part time: ' + elapsed + 's'
start = System.currentTimeMillis()
}
}
start = System.currentTimeMillis()
for (a = 0; a <5; a++) {
params.put('A', 'assembly'+a)
client.submit("g.addV('production_part').property('name',A).iterate()", params).all().get()
}
elapsed = (System.currentTimeMillis() - start) / 1000.0
println 'assembly time: ' + elapsed + 's'
start = System.currentTimeMillis()
for (a = 0; a<5; a++) {
params.put('an', 'assembly'+a)
for (p = 0; p <800000; p++) {
params.put('pn', 'part'+p)
rs = client.submit("g.V().has('production_part','name',an).as('a').V().has('production_part','name',pn).addE('has_part').from('a').iterate()", params).all()
// sync
if ( p % cores == 0) rs.get()
if (p % 10000 == 0) {
elapsed = (System.currentTimeMillis() - start) / 1000.0
println '' + a + ':' + p + ' edges time: ' + elapsed + 's'
start = System.currentTimeMillis()
}
}
}
println "Total time: " + ((System.currentTimeMillis() - total) / 1000.0)
cluster.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment