-package org.simantics.databoard.tests;\r
-\r
-/**\r
- *\r
- * @author Toni Kalajainen <toni.kalajainen@iki.fi>\r
- */\r
-public class TestByteVsInt {\r
-\r
- public static byte sum(byte a, byte b, byte c, byte d, byte e, byte f) {\r
- return (byte) (a+b+c+d+e+f);\r
- }\r
- \r
- public static int sum(int a, int b, int c, int d, int e, int f) {\r
- return a+b+c+d+e+f;\r
- }\r
- \r
- public static long sum(long a, long b, long c, long d, long e, long f) {\r
- return a+b+c+d+e+f;\r
- }\r
- \r
- public static void byteTest() {\r
- System.gc();\r
- {\r
- long x = System.nanoTime();\r
- byte a = 6, b=3, c=67, d=2, e=-53, f=1;\r
- for (int i=0; i<1000000; i++) {\r
- a = sum(a, b, c, d, e, f);\r
- b = sum(b, c, d, e, f, a);\r
- c = sum(c, d, e, f, a, b);\r
- d = sum(d, e, f, a, b, c);\r
- e = sum(e, f, a, b, c, d);\r
- f = sum(f, a, b, c, d, e); \r
- }\r
- long y = System.nanoTime();\r
- System.out.println("byte: "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);\r
- }\r
- }\r
- \r
- public static void intTest() {\r
- System.gc();\r
- {\r
- long x = System.nanoTime();\r
- int a = 6, b=3, c=67, d=2, e=-53, f=1;\r
- for (int i=0; i<1000000; i++) {\r
- a = sum(a, b, c, d, e, f);\r
- b = sum(b, c, d, e, f, a);\r
- c = sum(c, d, e, f, a, b);\r
- d = sum(d, e, f, a, b, c);\r
- e = sum(e, f, a, b, c, d);\r
- f = sum(f, a, b, c, d, e); \r
- }\r
- long y = System.nanoTime();\r
- System.out.println("int : "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);\r
- } \r
- }\r
- \r
- public static void longTest() {\r
- System.gc();\r
- {\r
- long x = System.nanoTime();\r
- long a = 6, b=3, c=67, d=2, e=-53, f=1;\r
- for (int i=0; i<1000000; i++) {\r
- a = sum(a, b, c, d, e, f);\r
- b = sum(b, c, d, e, f, a);\r
- c = sum(c, d, e, f, a, b);\r
- d = sum(d, e, f, a, b, c);\r
- e = sum(e, f, a, b, c, d);\r
- f = sum(f, a, b, c, d, e); \r
- }\r
- long y = System.nanoTime();\r
- System.out.println("long: "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);\r
- }\r
- }\r
- \r
- \r
- \r
- public static void main(String[] args) {\r
- \r
- byteTest();\r
- intTest();\r
- longTest();\r
- \r
- byteTest();\r
- intTest();\r
- longTest();\r
-\r
- byteTest();\r
- intTest();\r
- longTest();\r
- \r
- byteTest();\r
- intTest();\r
- longTest();\r
-\r
- byteTest();\r
- intTest();\r
- longTest();\r
-\r
- byteTest();\r
- intTest();\r
- longTest();\r
- \r
- }\r
- \r
-}\r
+package org.simantics.databoard.tests;
+
+/**
+ *
+ * @author Toni Kalajainen <toni.kalajainen@iki.fi>
+ */
+public class TestByteVsInt {
+
+ public static byte sum(byte a, byte b, byte c, byte d, byte e, byte f) {
+ return (byte) (a+b+c+d+e+f);
+ }
+
+ public static int sum(int a, int b, int c, int d, int e, int f) {
+ return a+b+c+d+e+f;
+ }
+
+ public static long sum(long a, long b, long c, long d, long e, long f) {
+ return a+b+c+d+e+f;
+ }
+
+ public static void byteTest() {
+ System.gc();
+ {
+ long x = System.nanoTime();
+ byte a = 6, b=3, c=67, d=2, e=-53, f=1;
+ for (int i=0; i<1000000; i++) {
+ a = sum(a, b, c, d, e, f);
+ b = sum(b, c, d, e, f, a);
+ c = sum(c, d, e, f, a, b);
+ d = sum(d, e, f, a, b, c);
+ e = sum(e, f, a, b, c, d);
+ f = sum(f, a, b, c, d, e);
+ }
+ long y = System.nanoTime();
+ System.out.println("byte: "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);
+ }
+ }
+
+ public static void intTest() {
+ System.gc();
+ {
+ long x = System.nanoTime();
+ int a = 6, b=3, c=67, d=2, e=-53, f=1;
+ for (int i=0; i<1000000; i++) {
+ a = sum(a, b, c, d, e, f);
+ b = sum(b, c, d, e, f, a);
+ c = sum(c, d, e, f, a, b);
+ d = sum(d, e, f, a, b, c);
+ e = sum(e, f, a, b, c, d);
+ f = sum(f, a, b, c, d, e);
+ }
+ long y = System.nanoTime();
+ System.out.println("int : "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);
+ }
+ }
+
+ public static void longTest() {
+ System.gc();
+ {
+ long x = System.nanoTime();
+ long a = 6, b=3, c=67, d=2, e=-53, f=1;
+ for (int i=0; i<1000000; i++) {
+ a = sum(a, b, c, d, e, f);
+ b = sum(b, c, d, e, f, a);
+ c = sum(c, d, e, f, a, b);
+ d = sum(d, e, f, a, b, c);
+ e = sum(e, f, a, b, c, d);
+ f = sum(f, a, b, c, d, e);
+ }
+ long y = System.nanoTime();
+ System.out.println("long: "+(y-x)/*+" (sum="+(a+b+c+d+e+f)+")"*/);
+ }
+ }
+
+
+
+ public static void main(String[] args) {
+
+ byteTest();
+ intTest();
+ longTest();
+
+ byteTest();
+ intTest();
+ longTest();
+
+ byteTest();
+ intTest();
+ longTest();
+
+ byteTest();
+ intTest();
+ longTest();
+
+ byteTest();
+ intTest();
+ longTest();
+
+ byteTest();
+ intTest();
+ longTest();
+
+ }
+
+}