1.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/api/Server.java Mon Feb 03 19:00:08 2014 +0100
1.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/api/Server.java Tue Feb 04 09:48:26 2014 +0100
1.3 @@ -77,6 +77,7 @@
1.4 private static final int MAX_CHANNEL_LEN = 256;
1.5 private static final char CHANNEL_SEPARATOR = '|'; //NOI18N
1.6 private final HttpServer http;
1.7 + private final static boolean measuringEnabled="true".equals(System.getProperty("tailwindmeasurementenabled")); //NOI18N
1.8
1.9 private Server(
1.10 @NonNull final Union2<Integer,Pair<Integer,Integer>> portCfg,
1.11 @@ -221,6 +222,9 @@
1.12 public void onMessage(WebSocket socket, byte[] bytes) {
1.13 final ByteBuffer bb = ByteBuffer.wrap(bytes);
1.14 final CharBuffer cb = UTF8.decode(bb);
1.15 + if (measuringEnabled) {
1.16 + Utilities.insertStartTime(System.currentTimeMillis(), socket.hashCode());
1.17 + }
1.18 onMessage(socket, cb.toString());
1.19 }
1.20 }
2.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/endpoint/EndPoint.java Mon Feb 03 19:00:08 2014 +0100
2.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/endpoint/EndPoint.java Tue Feb 04 09:48:26 2014 +0100
2.3 @@ -106,6 +106,7 @@
2.4 private static final Object handlersCacheLock = new Object();
2.5 //@GuardedBy("handlersCacheLock")
2.6 private static Map<String,Collection<RequestHandler<?,?>>> handlersCache;
2.7 + private final static boolean measuringEnabled="true".equals(System.getProperty("tailwindmeasurementenabled")); //NOI18N
2.8 private final Object cacheLock = new Object();
2.9 //@GuardedBy("cacheLock")
2.10 private Map<RequestKind, RequestHandler<Request, RequestKind>> cache;
2.11 @@ -231,9 +232,12 @@
2.12 if (closed) {
2.13 throw new IllegalStateException("Env already closed"); //NOI18N
2.14 }
2.15 - ws.send(message == null ?
2.16 - "null" : //NOI18N
2.17 - message);
2.18 + if (measuringEnabled) {
2.19 + long timeinside=Utilities.getMeasuredTime(System.currentTimeMillis(), ws.hashCode());
2.20 + ws.send(message == null ? "null" :( (timeinside<0)? message : (message +"@"+timeinside) ) ); //NOI18N
2.21 + } else {
2.22 + ws.send(message == null ? "null" : ( message) ); //NOI18N
2.23 + }
2.24 }
2.25
2.26 public void setProperty(
3.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/endpoint/Utilities.java Mon Feb 03 19:00:08 2014 +0100
3.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/endpoint/Utilities.java Tue Feb 04 09:48:26 2014 +0100
3.3 @@ -42,6 +42,9 @@
3.4
3.5 package org.netbeans.modules.dew4nb.endpoint;
3.6
3.7 +import java.util.HashMap;
3.8 +import java.util.logging.Level;
3.9 +import java.util.logging.Logger;
3.10 import net.java.html.json.Model;
3.11 import net.java.html.json.Property;
3.12 import org.netbeans.api.annotations.common.NonNull;
3.13 @@ -56,6 +59,8 @@
3.14 private Utilities() {
3.15 throw new IllegalStateException("No instance allowed."); //NOI18N
3.16 }
3.17 + private static final HashMap<Integer,Long> measurements = new HashMap<>();
3.18 + private static final Logger LOG = Logger.getLogger(Utilities.class.getName());
3.19
3.20 @NonNull
3.21 public static Failure newFailure (
3.22 @@ -84,6 +89,25 @@
3.23 return fail;
3.24 }
3.25
3.26 + public static void insertStartTime(long starttime, int hash) {
3.27 + measurements.put(hash, starttime);
3.28 + Log("Operation "+hash+" STARTED at starttime: "+starttime); //NOI18N
3.29 + }
3.30 +
3.31 + private static void Log(String message) {
3.32 + LOG.log(Level.INFO, message);
3.33 + }
3.34 +
3.35 + public static long getMeasuredTime(long endtime, int hash) {
3.36 + Long start = measurements.get(hash);
3.37 + long result=-1;
3.38 + if (start!=null) {
3.39 + result = endtime - start;
3.40 + }
3.41 + Log("Operation "+hash+" FINISHED at: "+endtime+" Duration="+result+" ms"); //NOI18N
3.42 + return result;
3.43 + }
3.44 +
3.45 @Model(className = "Failure", properties = {
3.46 @Property(name="status", type=Status.class),
3.47 @Property(name = "type", type = String.class),