]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/StringUTFTest.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / scratch / org / simantics / databoard / tests / StringUTFTest.java
index 1a59ed3e2b7ded3c4fe219030b336200078a766b..569b67b301bc7e1b626ab2c9b9ff0ad4b50ef9af 100644 (file)
@@ -1,78 +1,78 @@
-package org.simantics.databoard.tests;\r
-\r
-import java.io.ByteArrayInputStream;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.DataInputStream;\r
-import java.io.DataOutputStream;\r
-import java.nio.charset.Charset;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.StringBinding;\r
-\r
-/**\r
- *\r
- * @author Toni Kalajainen <toni.kalajainen@iki.fi>\r
- */\r
-public class StringUTFTest {\r
-       \r
-       public static void main(String[] args) throws Exception {\r
-               \r
-               StringBinding b = Bindings.STRING;\r
-               int c = 10000;\r
-               String[] strs = new String[c];\r
-               for (int i=0; i<c; i++) strs[i] = (String) b.createRandom(i);\r
-               \r
-                               \r
-               {\r
-                       ByteArrayOutputStream baos = new ByteArrayOutputStream( 10*1024*1024 );\r
-                       DataOutputStream dos = new DataOutputStream( baos );            \r
-                       System.gc();\r
-                       long x = System.nanoTime();\r
-                       for (int i=0; i<c; i++) {\r
-                               dos.writeUTF(strs[i]);\r
-                       }\r
-                       long y = System.nanoTime() - x;\r
-                       System.out.println("DataOutputStream.writeUTF: "+y);\r
-\r
-                       byte[] data = baos.toByteArray();\r
-                       DataInputStream dis = new DataInputStream( new ByteArrayInputStream( data ) );\r
-                       x = System.nanoTime();\r
-                       for (int i=0; i<c; i++) {\r
-                               dis.readUTF();\r
-                       }\r
-                       y = System.nanoTime() - x;\r
-                       System.out.println("DataOutputStream.readUTF : "+y);\r
-               }\r
-               \r
-               {\r
-                       Charset cs = Charset.forName("UTF8");\r
-                       ByteArrayOutputStream baos = new ByteArrayOutputStream( 10*1024*1024 );\r
-                       DataOutputStream dos = new DataOutputStream( baos );            \r
-                       System.gc();\r
-                       long x = System.nanoTime();\r
-                       for (int i=0; i<c; i++) {\r
-                               byte[] data = strs[i].getBytes(cs);\r
-                               dos.writeInt(data.length);\r
-                               dos.write(data);\r
-                       }\r
-                       long y = System.nanoTime() - x;\r
-                       System.out.println("String#getBytes(cs)      : "+y);\r
-\r
-                       \r
-                       byte[] strData = new byte[1024];\r
-                       byte[] data = baos.toByteArray();\r
-                       DataInputStream dis = new DataInputStream( new ByteArrayInputStream( data ) );\r
-                       x = System.nanoTime();\r
-                       for (int i=0; i<c; i++) {\r
-                               int len = dis.readInt();\r
-                               dis.read(strData, 0, len);\r
-                               new String(strData, cs);\r
-                       }\r
-                       y = System.nanoTime() - x;\r
-                       System.out.println("new String(byte[], cs)   : "+y);\r
-               }\r
-               \r
-               \r
-       }\r
-\r
-}\r
+package org.simantics.databoard.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.nio.charset.Charset;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.StringBinding;
+
+/**
+ *
+ * @author Toni Kalajainen <toni.kalajainen@iki.fi>
+ */
+public class StringUTFTest {
+       
+       public static void main(String[] args) throws Exception {
+               
+               StringBinding b = Bindings.STRING;
+               int c = 10000;
+               String[] strs = new String[c];
+               for (int i=0; i<c; i++) strs[i] = (String) b.createRandom(i);
+               
+                               
+               {
+                       ByteArrayOutputStream baos = new ByteArrayOutputStream( 10*1024*1024 );
+                       DataOutputStream dos = new DataOutputStream( baos );            
+                       System.gc();
+                       long x = System.nanoTime();
+                       for (int i=0; i<c; i++) {
+                               dos.writeUTF(strs[i]);
+                       }
+                       long y = System.nanoTime() - x;
+                       System.out.println("DataOutputStream.writeUTF: "+y);
+
+                       byte[] data = baos.toByteArray();
+                       DataInputStream dis = new DataInputStream( new ByteArrayInputStream( data ) );
+                       x = System.nanoTime();
+                       for (int i=0; i<c; i++) {
+                               dis.readUTF();
+                       }
+                       y = System.nanoTime() - x;
+                       System.out.println("DataOutputStream.readUTF : "+y);
+               }
+               
+               {
+                       Charset cs = Charset.forName("UTF8");
+                       ByteArrayOutputStream baos = new ByteArrayOutputStream( 10*1024*1024 );
+                       DataOutputStream dos = new DataOutputStream( baos );            
+                       System.gc();
+                       long x = System.nanoTime();
+                       for (int i=0; i<c; i++) {
+                               byte[] data = strs[i].getBytes(cs);
+                               dos.writeInt(data.length);
+                               dos.write(data);
+                       }
+                       long y = System.nanoTime() - x;
+                       System.out.println("String#getBytes(cs)      : "+y);
+
+                       
+                       byte[] strData = new byte[1024];
+                       byte[] data = baos.toByteArray();
+                       DataInputStream dis = new DataInputStream( new ByteArrayInputStream( data ) );
+                       x = System.nanoTime();
+                       for (int i=0; i<c; i++) {
+                               int len = dis.readInt();
+                               dis.read(strData, 0, len);
+                               new String(strData, cs);
+                       }
+                       y = System.nanoTime() - x;
+                       System.out.println("new String(byte[], cs)   : "+y);
+               }
+               
+               
+       }
+
+}