New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testcase for Issue 72: LayerNodeIndex:add() performance #73

Merged
merged 2 commits into from Jan 1, 2013
Jump to file or symbol
Failed to load files and symbols.
+45 −0
Diff settings

Always

Just for now

Next

Add testcase for issue #72 : performance of LayerNodeIndex:add()

  • Loading branch information...
jonathanwin committed Nov 14, 2012
commit 77bf38c885d012ad77f1b381d6b6826a534673cb
@@ -45,6 +45,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import javax.script.Bindings;
import javax.script.ScriptContext;
@@ -204,4 +205,48 @@ public void testWithinDistanceIndexViaCypher()
ExecutionResult result = engine.execute( "start n=node:layer3('withinDistance:[44.44, 33.32, 5.0]') return n" );
System.out.println( result.toString() );
}
/**
* Test the performance of LayerNodeIndex.add()
* Insert up to 100K nodes into the database, and into the index, randomly distributed over [-80,+80][-170+170]
* Calculate speed over 100-node groups, fail if speed falls under 50 adds/second (typical max speed here 500 adds/second)
*/
@Test
public void testAddPerformance()
{
Map<String, String> config = SpatialIndexProvider.SIMPLE_POINT_CONFIG;
IndexManager indexMan = db.index();
Index<Node> index = indexMan.forNodes( "pointslayer", config );
Transaction tx = db.beginTx();
try {
Random r = new Random();
final int stepping = 100;
long start = System.currentTimeMillis();
long previous = start;
for (int i=1; i<=100000; i++) {
Node newnode = db.createNode();
newnode.setProperty( "lat", (double) r.nextDouble()*160-80 );
newnode.setProperty( "lon", (double) r.nextDouble()*340-170 );
index.add(newnode, "dummy", "value");
if ( i%stepping == 0) {
long now = System.currentTimeMillis();
long duration = now-start;
long stepDuration = now-previous;
double speed = stepping / (stepDuration/1000.0);
System.out.println("testAddPerformance(): "+ stepping +" nodes added in "+ stepDuration +"ms, total "+ i +" in "+ duration +"ms, speed: "+ speed +" adds per second");
final double targetSpeed = 50.0; // Quite conservative, max speed here 500 adds per second
assertTrue("add is too slow at size:"+i+" ("+speed+" adds per second <= "+targetSpeed+")", speed > targetSpeed);
previous = now;
}
}
tx.success();
} finally {
System.out.println("testAddPerformance(): finishing transaction");
tx.finish();
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.