From 3c34c83e6d3660b04e6bd2c0fb7bc4e4407f1502 Mon Sep 17 00:00:00 2001 From: villberg Date: Mon, 24 Nov 2014 10:47:53 +0000 Subject: [PATCH] (refs #5495) Performance optimizations for Project Game git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30595 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../manager/SysdynGameExperimentBase.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java index 31314bbd..4a473bd9 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java @@ -45,10 +45,10 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment { protected double stepDuration = DEFAULT_STEP_DURATION; protected int savePer = 1; - protected HashMap subscriptionIndexes; + public HashMap subscriptionIndexes; protected double[] currentValues; // Current values from FMU. Updated with updateSubscriptions - THashMap results; + TDoubleArrayList[] results; public String[] subscription; @@ -122,7 +122,7 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment { monitor.subTask("Save results (time = " + time + ")"); for(int k = 0; k < subscription.length; k++) { - setResults(time, subscription[k], currentValues[k]); + setResults(time, k, currentValues[k]); } lastResultTime = time; @@ -131,11 +131,11 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment { private double lastResultTime = Double.NaN; - public void setResults(double time, String key, Double value) { - TDoubleArrayList list = results.get(key); + public void setResults(double time, int index, Double value) { + TDoubleArrayList list = results[index]; if(list == null) { list = new TDoubleArrayList(); - results.put(key, list); + results[index] = list; } if(time == lastResultTime) { list.set(list.size()-1, value); @@ -147,14 +147,20 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment { public void clearResults() { lastResultTime = Double.NaN; - results.clear(); + for(int i=0;i