Skip to content

Instantly share code, notes, and snippets.

@amischler
Created January 8, 2015 16:10
Show Gist options
  • Save amischler/3966cdc6410203011f08 to your computer and use it in GitHub Desktop.
Save amischler/3966cdc6410203011f08 to your computer and use it in GitHub Desktop.
TestUpdateChildNodePerformance
package org.jcrom.modeshape;
import org.jcrom.Jcrom;
import org.jcrom.entities.Child;
import org.jcrom.entities.Parent;
import org.junit.Test;
import org.modeshape.test.ModeShapeSingleUseTest;
/**
*/
public class TestUpdateChildNodePerformance extends ModeShapeSingleUseTest {
@Test
public void testPerformance() {
Jcrom jcrom = new Jcrom(false, true);
jcrom.map(Parent.class);
jcrom.map(Child.class);
ParentDAO parentDAO = new ParentDAO(session, jcrom);
Parent parent = new Parent();
parent.setName("Parent");
parent.setPath("/");
parentDAO.create(parent);
for (int i = 0; i < 1000; i++) {
Child child = new Child();
child.setName("Child " + i);
parent.getChildren().add(child);
}
long startTime = System.currentTimeMillis();
parentDAO.update(parent);
long firstUpdate = System.currentTimeMillis();
System.out.println("First update took: " + (firstUpdate - startTime) + " ms");
parentDAO.update(parent);
System.out.println("Second update took: " + (System.currentTimeMillis() - firstUpdate) + " ms");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment