X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.history%2Ftest%2Forg%2Fsimantics%2Fhistory%2Ftest%2FTestPerformance.java;h=93b2670c2fa37259fc7f4a9f3905b286077485c7;hb=38f8cf1831e50990f7053dfaa20db64a6342015f;hp=a70da5efb9a5b29af92dd782112940c4f00e5426;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.history/test/org/simantics/history/test/TestPerformance.java b/bundles/org.simantics.history/test/org/simantics/history/test/TestPerformance.java index a70da5efb..93b2670c2 100644 --- a/bundles/org.simantics.history/test/org/simantics/history/test/TestPerformance.java +++ b/bundles/org.simantics.history/test/org/simantics/history/test/TestPerformance.java @@ -1,106 +1,106 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 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.history.test; - -import java.io.File; -import java.io.IOException; - -import org.junit.Test; -import org.simantics.databoard.Bindings; -import org.simantics.databoard.Datatypes; -import org.simantics.databoard.type.RecordType; -import org.simantics.history.Collector; -import org.simantics.history.History; -import org.simantics.history.HistoryManager; -import org.simantics.history.impl.CollectorImpl; -import org.simantics.history.impl.CollectorState; -import org.simantics.history.util.subscription.SubscriptionItem; -import org.simantics.history.util.subscription.SamplingFormat; -import org.simantics.utils.FileUtils; - -public class TestPerformance { - - static final double NaN = Double.NaN; - - // Time 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 - double[] data1 = { 5.0, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 7.0, 8.0, 9.0, NaN,10.0, NaN, NaN, NaN }; - double[] data2 = { 5.0, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 7.0, 8.0, 9.0,10.0, 9.0, 5.0, 4.0, 3.0 }; - byte[] data3 = { 5, 6, 7, 8, 9, 10, 9, 5, 4, 3 }; - - // Subscription formats - SamplingFormat simple, allfields, vector, minmax, byteformat, string; - - // History - HistoryManager historian; - File workarea; - Collector collector; - - @Test - public void testPerformance() throws Exception { - - File workarea = FileUtils.createTmpDir(); - - byteformat = new SamplingFormat(); - byteformat.formatId = "byte"; - byteformat.format = new RecordType(); - RecordType format = (RecordType) (byteformat.format = new RecordType()); - format.addComponent("time", Datatypes.DOUBLE); - format.addComponent("endTime", Datatypes.DOUBLE); - format.addComponent("value", Datatypes.BYTE); - format.addComponent("lastValue", Datatypes.BYTE); - format.addComponent("min", Datatypes.BYTE); - format.addComponent("max", Datatypes.BYTE); - format.addComponent("avg", Datatypes.DOUBLE); - format.addComponent("median", Datatypes.BYTE); - format.addComponent("quality", Datatypes.BYTE); - format.addComponent("count", Datatypes.INTEGER); - byteformat.interval = NaN; - byteformat.deadband = NaN; - - CollectorState cs; - // Write data - for (int z=0; z<20; z++) { - cs = new CollectorState(); - historian = History.openFileHistory(workarea); - collector = new CollectorImpl( historian ); - - // 2. Write data - SubscriptionItem hi = SubscriptionItem.createItem("MyVariable", "MySubscription", byteformat ); - historian.create( hi ); - collector.addItem( hi ); - System.gc(); - long startTime = System.nanoTime(); - double[] data = data2; - for (int j=0; j<10000; j++) { - for (int i=0; i