X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fscratch%2Forg%2Fsimantics%2Fdataboard%2Ftests%2FTestByteVsInt.java;h=6c2370694a8412922b020a7f27a5945ba99d56d6;hb=293ccfa5eb545cf7c541703a5747d85da662ec27;hp=a1fb05b81ae1706109bd63271393bc94382a18ea;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/TestByteVsInt.java b/bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/TestByteVsInt.java index a1fb05b81..6c2370694 100644 --- a/bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/TestByteVsInt.java +++ b/bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/TestByteVsInt.java @@ -1,105 +1,105 @@ -package org.simantics.databoard.tests; - -/** - * - * @author Toni Kalajainen - */ -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(); - - } - -} +package org.simantics.databoard.tests; + +/** + * + * @author Toni Kalajainen + */ +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(); + + } + +}