]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added serialization-time measurement to Ticket695
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 12 Apr 2009 09:20:58 +0000 (09:20 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Sun, 12 Apr 2009 09:20:58 +0000 (09:20 +0000)
svn changeset:7388/svn branch:6.0

src/com/itmill/toolkit/tests/tickets/Ticket695.java

index fc040d8ba384fe378ab80ff54507573030ef8421..8e45c4ca5cc90b541fa0c5b88159eb3aa5a4d166 100644 (file)
@@ -3,6 +3,7 @@ package com.itmill.toolkit.tests.tickets;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
+
 import com.itmill.toolkit.Application;
 import com.itmill.toolkit.ui.Button;
 import com.itmill.toolkit.ui.Window;
@@ -10,31 +11,33 @@ import com.itmill.toolkit.ui.Button.ClickEvent;
 
 public class Ticket695 extends Application {
 
-       private static final long serialVersionUID = 3803150085397590662L;
-
-       @Override
-       public void init() {
-               final Window w = new Window("Serialization test #695");
-               setMainWindow(w);
-               Button b = new Button("Serialize ApplicationContext");
-               w.addComponent(b);
-               b.addListener(new Button.ClickListener() {
-
-                       public void buttonClick(ClickEvent event) {
-                               ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-                               try {
-                                       ObjectOutputStream oos = new ObjectOutputStream(buffer);
-                                       oos.writeObject(getContext());
-                                       w.showNotification("ApplicationContext serialized ("
-                                                       + buffer.size() + "bytes)");
-                               } catch (IOException e) {
-                                       e.printStackTrace();
-                                       w
-                                                       .showNotification("ApplicationContext serialization failed - see console for stacktrace");
-                               }
-
-                       }
-               });
-       }
+    private static final long serialVersionUID = 3803150085397590662L;
+
+    @Override
+    public void init() {
+        final Window w = new Window("Serialization test #695");
+        setMainWindow(w);
+        Button b = new Button("Serialize ApplicationContext");
+        w.addComponent(b);
+        b.addListener(new Button.ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+                try {
+                    ObjectOutputStream oos = new ObjectOutputStream(buffer);
+                    long t = System.currentTimeMillis();
+                    oos.writeObject(getContext());
+                    w.showNotification("ApplicationContext serialized ("
+                            + buffer.size() + "bytes) in "
+                            + (System.currentTimeMillis() - t) + "ms");
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    w
+                            .showNotification("ApplicationContext serialization failed - see console for stacktrace");
+                }
+
+            }
+        });
+    }
 
 }