Created
November 20, 2012 22:47
-
-
Save gak/4121797 to your computer and use it in GitHub Desktop.
Groovy script to test Titan edge lookup performance with different keys and labels
This file contains hidden or 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
g = TitanFactory.open('test.properties') | |
r = new Random() | |
edges = 1e4 | |
key = "poozd" + r.nextInt().toString() + r.nextInt().toString() | |
label = key + "s" | |
def newKey(g, name, type) { | |
return g | |
.makeType() | |
.name(name) | |
//.indexed() | |
//.simple() | |
.functional() | |
//.unique() | |
.dataType(type) | |
.makePropertyKey() | |
} | |
def newLabel(g, name, key, key2) { | |
return g | |
.makeType() | |
.name(name) | |
.primaryKey(key, key2) | |
.makeEdgeLabel() | |
} | |
def t(g) { | |
g.stopTransaction(SUCCESS) | |
g.startTransaction() | |
} | |
type = newKey(g, key, Integer.class) | |
// newLabel(g, label, type) | |
type2 = newKey(g, key + 'poo', String.class) | |
newLabel(g, label, type, type2) | |
root = g.addVertex() | |
t(g) | |
(1..edges).each { | |
root = g.getVertex(root.id) | |
value = r.nextInt() | |
edge = g.addVertex(null) | |
asdfvalue = 'asdf' + (it % 10) | |
g.addEdge(root, edge, label, [(key): value, (key + 'poo'): asdfvalue]) | |
} | |
def go(g, name, root, closure) { | |
g.stopTransaction(SUCCESS) | |
g.startTransaction() | |
root = g.getVertex(root.id) | |
t0 = new Date().time | |
println "result: " + closure(root) | |
t1 = new Date().time | |
println name + ": " + (t1 - t0) + "ms" | |
} | |
go(g, ".outE()", root, { v -> return v.outE(label).inV().count()}) | |
go(g, ".outE().has()", root, { v -> return v.outE(label).has(key, value).inV().count()}) | |
go(g, ".outE().interval()", root, { v -> return v.outE(label).interval(key, 0, 10000000).inV().count()}) | |
go(g, ".outE().interval()", root, { v -> return v.outE(label).has(key + 'poo', 'asdf5').interval(key, 0, 10000000).inV().count()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment