[exo-jcr-commits] exo-jcr SVN: r823 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Nov 24 05:01:09 EST 2009
Author: tolusha
Date: 2009-11-24 05:01:08 -0500 (Tue, 24 Nov 2009)
New Revision: 823
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
Log:
EXOJCR-221: getNodes from different session perfomance test
Added: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java 2009-11-24 10:01:08 UTC (rev 823)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.load.perf;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko at exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TestGetNodesPerf extends JcrAPIBaseTest
+{
+ private static final String testName = "testRoot";
+
+ private static final int sessionCount = 20;
+
+ private Session[] sessions = new Session[sessionCount];
+
+ private GetNodesThread[] threads = new GetNodesThread[sessionCount];
+
+ public void testGetNodes() throws Exception
+ {
+ for (int i = 0; i < sessionCount; i++)
+ {
+ sessions[i] = (SessionImpl)repository.login(credentials, "ws");
+ }
+
+ Node testRoot = session.getRootNode().addNode(testName);
+ session.save();
+
+ log.info("adding...");
+ int nodesCount = 50000;
+ for (int i = 0; i < nodesCount; i++)
+ {
+ testRoot.addNode("_" + i + "_node");
+ }
+ log.info("saving...");
+ session.save();
+
+ log.info("waiting for 10 seconds...");
+ Thread.sleep(10000);
+
+ log.info("getting nodes...");
+ for (int i = 0; i < sessionCount; i++)
+ {
+ threads[i] = new GetNodesThread(sessions[i]);
+ threads[i].start();
+ }
+
+ outer : while (true)
+ {
+ for (int i = 0; i < sessionCount; i++)
+ {
+ if (threads[i].isAlive())
+ {
+ Thread.sleep(1000);
+ continue outer;
+ }
+ }
+
+ break;
+ }
+
+ log.info("Test finished");
+ }
+
+ private class GetNodesThread extends Thread
+ {
+ private final Session curSession;
+
+ GetNodesThread(Session session)
+ {
+ this.curSession = session;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ Node testRoot = curSession.getRootNode().getNode(testName);
+
+ long startTime = System.currentTimeMillis();
+ testRoot.getNodes();
+ log.info("Total time: " + (System.currentTimeMillis() - startTime) / 1000 + "s");
+ }
+ catch (RepositoryException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestGetNodesPerf.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the exo-jcr-commits
mailing list