]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.history/test/org/simantics/history/test/TestBindingPerformance.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.history / test / org / simantics / history / test / TestBindingPerformance.java
index b047b3f6f0c2db8c22060a84c373d349836a057a..9e5dea6432fb6c42b422176c42d62bba050e7467 100644 (file)
@@ -1,75 +1,75 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.history.test;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.history.util.ValueBand;\r
-\r
-/**\r
- * Which is faster binding to use? \r
- * \r
- *    1. Write to record with reflection\r
- *    \r
- *    \r
- *    \r
- *    2. Write to object array with boxed primitives \r
- *    \r
- *    \r
- *\r
- */\r
-public class TestBindingPerformance {\r
-       \r
-       public static class Sample {\r
-               public double time, endTime, value, lastValue, min, max, avg, median;\r
-               public byte quality;\r
-               public int count;\r
-       }       \r
-       \r
-       public static void test( Binding b ) throws Exception {\r
-               \r
-               Object s = b.createDefault();\r
-               ValueBand band = new ValueBand( b, s );\r
-                               \r
-               for (int i=0; i<10000000; i++) {\r
-                       double value = i;\r
-                       band.setTime(Bindings.DOUBLE, value);\r
-                       band.setEndTime(Bindings.DOUBLE, value);\r
-                       band.setValue(Bindings.DOUBLE, value);\r
-                       band.setLastValue(Bindings.DOUBLE, value);\r
-                       band.setMin(Bindings.DOUBLE, value);\r
-                       band.setMax(Bindings.DOUBLE, value);\r
-                       band.setAvg(Bindings.DOUBLE, value);\r
-                       band.setMedian(Bindings.DOUBLE, value);\r
-               }\r
-               \r
-       }\r
-       \r
-       public static void main(String[] args) throws Exception {\r
-               \r
-               Binding b1 = Bindings.getBinding( Sample.class );\r
-               Binding b2 = Bindings.getBinding( b1.type() );\r
-               \r
-               test(b1);\r
-               test(b2);\r
-               \r
-               long ct = System.currentTimeMillis();\r
-               test(b1);\r
-               System.out.println(System.currentTimeMillis()-ct);\r
-\r
-               ct = System.currentTimeMillis();\r
-               test(b2);\r
-               System.out.println(System.currentTimeMillis()-ct);\r
-               \r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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 org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.history.util.ValueBand;
+
+/**
+ * Which is faster binding to use? 
+ * 
+ *    1. Write to record with reflection
+ *    
+ *    
+ *    
+ *    2. Write to object array with boxed primitives 
+ *    
+ *    
+ *
+ */
+public class TestBindingPerformance {
+       
+       public static class Sample {
+               public double time, endTime, value, lastValue, min, max, avg, median;
+               public byte quality;
+               public int count;
+       }       
+       
+       public static void test( Binding b ) throws Exception {
+               
+               Object s = b.createDefault();
+               ValueBand band = new ValueBand( b, s );
+                               
+               for (int i=0; i<10000000; i++) {
+                       double value = i;
+                       band.setTime(Bindings.DOUBLE, value);
+                       band.setEndTime(Bindings.DOUBLE, value);
+                       band.setValue(Bindings.DOUBLE, value);
+                       band.setLastValue(Bindings.DOUBLE, value);
+                       band.setMin(Bindings.DOUBLE, value);
+                       band.setMax(Bindings.DOUBLE, value);
+                       band.setAvg(Bindings.DOUBLE, value);
+                       band.setMedian(Bindings.DOUBLE, value);
+               }
+               
+       }
+       
+       public static void main(String[] args) throws Exception {
+               
+               Binding b1 = Bindings.getBinding( Sample.class );
+               Binding b2 = Bindings.getBinding( b1.type() );
+               
+               test(b1);
+               test(b2);
+               
+               long ct = System.currentTimeMillis();
+               test(b1);
+               System.out.println(System.currentTimeMillis()-ct);
+
+               ct = System.currentTimeMillis();
+               test(b2);
+               System.out.println(System.currentTimeMillis()-ct);
+               
+       }
+
+}