X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fperformance%2Fread%2FReadHierarchicalNamesAndTypes.java;fp=tests%2Forg.simantics.db.tests%2Fsrc%2Forg%2Fsimantics%2Fdb%2Ftests%2Fperformance%2Fread%2FReadHierarchicalNamesAndTypes.java;h=6291cba4b05621a10f8189c6a8df2eca28505f4d;hb=67fd62f9c742337ec80eef658192db198a0efaac;hp=0000000000000000000000000000000000000000;hpb=cde82ba81327d5515fdca362f7f4c70f5103ae80;p=simantics%2Fplatform.git diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/performance/read/ReadHierarchicalNamesAndTypes.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/performance/read/ReadHierarchicalNamesAndTypes.java new file mode 100644 index 000000000..6291cba4b --- /dev/null +++ b/tests/org.simantics.db.tests/src/org/simantics/db/tests/performance/read/ReadHierarchicalNamesAndTypes.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.tests.performance.read; + +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.common.TransactionPolicyKeep; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.Read; +import org.simantics.db.request.WriteOnlyResult; +import org.simantics.db.service.QueryControl; +import org.simantics.db.service.TransactionPolicySupport; +import org.simantics.db.testing.base.ExistingDatabaseTest; +import org.simantics.layer0.Layer0; + +/* + * + * Some statistics: + * + * == With WriteOnlyGraph === + * + * -Creation of 50M write only resources (50M res, 0 stm) + * -Stream off = 1.88s + * -UpdateTransaction off = 5.11s + * -Creation of 50M write only resources with single instanceof (50M res, 50M stm) + * -Stream off = 5.36s + * -UpdateTransaction off = 16.05s + * -Creation of 50M write only resources with instanceof and consists of hierarchy (50M res, 150M stm) + * -Stream off = 12.20s + * -UpdateTransaction off = 39.3s + * -Creation of 50M write only resources with string name (no instanceof) (100M res, 150M stm) + * -Stream off = 31.66s + * -Creation of 50M write only resources full (100M res, 300M stm) + * -Stream off = 43.39s + * + * == With ClusterBuilder == + * + * -Creation of 50M write only resources (50M res, 0 stm) + * -Stream off = 1.62s + * -UpdateTransaction off = 5.07 + * -Creation of 50M write only resources with single instanceof (50M res, 50M stm) + * -Stream off = 3.33s + * -UpdateTransaction off = 14.26s + * -Creation of 50M write only resources with instanceof and consists of hierarchy (50M res, 150M stm) + * -Stream off = 6.09s + * -UpdateTransaction off = 32.42s + * -Creation of 50M write only resources with string name (no instanceof) (100M res, 150M stm) + * -Stream off = 23.97s + * -Creation of 50M write only resources full (100M res, 300M stm, 50M literals) + * -Stream off = 27.85s + * + */ +public class ReadHierarchicalNamesAndTypes extends ExistingDatabaseTest { + + final private static String name = "name"; + int[] sizes = { 244, 64, 64 }; + + private Resource time(String label, WriteOnlyResult request) throws DatabaseException { + + long start = System.nanoTime(); + Resource result = getSession().syncRequest(request); + long duration = System.nanoTime() - start; + System.out.println(label + " = " + 1e-9*duration); + return result; + + } + + private void time(String label, Read request) throws DatabaseException { + + long start = System.nanoTime(); + getSession().syncRequest(request); + long duration = System.nanoTime() - start; + System.out.println(label + " = " + 1e-9*duration); + + } + +// private void clearCaches() throws DatabaseException { +// +// Session session = Tests.getTestHandler().getSession(); +// QueryControl cc = session.getService(QueryControl.class); +// ClusterControl ccr = session.getService(ClusterControl.class); +// cc.flush(); +// ccr.collectClusters(ccr.used()); +// System.gc(); +// System.gc(); +// System.gc(); +// +// } + + public void test() throws Exception { + + Layer0.getInstance(getSession()); + + getSession().registerService(TransactionPolicySupport.class, new TransactionPolicyKeep()); +// getSession().registerService(TransactionPolicySupport.class, new TransactionPolicyRelease()); + + // First build the test data + Resource root = time("write", HierarchicalNames.writeOnly(name, sizes)); + + // Read everything after write + time("response", HierarchicalNames.readAsyncTypes(root)); + + Session session = getSession(); + QueryControl cc = session.getService(QueryControl.class); + cc.flush(); + + System.out.println("wait"); + Thread.sleep(3000); + System.out.println("wait done"); + + // Clusters are now loaded + time("async", HierarchicalNames.readAsyncTypes(root)); +// System.err.println("done"); +// time("async2", HierarchicalNames.readAsync2(root)); +// time("sync", HierarchicalNames.readSync(root)); +// time("sync2", HierarchicalNames.readSync2(root)); + + } + +}