use of org.structr.core.graph.BulkDeleteCommand in project structr by structr.
the class PerformanceTest method testPerformanceOfNodeDeletion.
@Test
public void testPerformanceOfNodeDeletion() {
final App app = StructrApp.getInstance(setup());
final List<TestOne> nodes = new LinkedList<>();
final int number = 1000;
try {
try (final Tx tx = app.tx()) {
nodes.addAll(createNodes(app, TestOne.class, number));
tx.success();
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
// start measuring
final long t0 = System.currentTimeMillis();
try {
final BulkDeleteCommand cmd = app.command(BulkDeleteCommand.class);
try (final Tx tx = app.tx()) {
final Iterator<GraphObject> iterator = (Iterator) nodes.iterator();
cmd.bulkDelete(iterator);
tx.success();
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
final long t1 = System.currentTimeMillis();
DecimalFormat decimalFormat = new DecimalFormat("0.000000000", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
Double time = (t1 - t0) / 1000.0;
Double rate = number / ((t1 - t0) / 1000.0);
logger.info("Deleted {} nodes in {} seconds ({} per s)", number, decimalFormat.format(time), decimalFormat.format(rate));
assertTrue("Deletion rate of nodes too low, expected > 100, was " + rate, rate > 50);
}
Aggregations