launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/Console.java
changeset 1860 4ce38f21f4cd
parent 1787 ea12a3bb4b33
child 1927 cff680298793
     1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/Console.java	Tue Feb 24 11:12:53 2015 +0100
     1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/Console.java	Tue Jan 26 04:36:23 2016 +0100
     1.3 @@ -43,7 +43,10 @@
     1.4      private static native void setAttr(String id, String attr, Object value);
     1.5  
     1.6      @JavaScriptBody(args = { "elem", "attr", "value" }, body = "elem[attr] = value;")
     1.7 -    private static native void setAttr(Object id, String attr, Object value);
     1.8 +    private static native void setAttr(Object elem, String attr, Object value);
     1.9 +
    1.10 +    @JavaScriptBody(args = {}, body = "return new Date().getTime()")
    1.11 +    private static native double getTime();
    1.12      
    1.13      private static void closeWindow() {}
    1.14  
    1.15 @@ -175,9 +178,11 @@
    1.16                      log("Processing \"" + arr[0] + "\" for " + retries + " time");
    1.17                  }
    1.18                  Object result = retries++ >= 100 ? "java.lang.InterruptedException:timeout(" + retries + ")" : c.runTest();
    1.19 +                String reply = "?request=" + c.getRequestId() + "&time=" + c.time + "&result=" + result;
    1.20 +                log("Sending back: ..." + reply);
    1.21                  finishTest(c, result);
    1.22                  
    1.23 -                String u = url + "?request=" + c.getRequestId() + "&result=" + result;
    1.24 +                String u = url + reply;
    1.25                  new Request(url, u);
    1.26              } catch (Exception ex) {
    1.27                  if (ex instanceof InterruptedException) {
    1.28 @@ -264,6 +269,7 @@
    1.29      
    1.30      private static final class Case {
    1.31          private final Object data;
    1.32 +        private double time;
    1.33          private Object inst;
    1.34  
    1.35          private Case(Object data) {
    1.36 @@ -315,8 +321,8 @@
    1.37              Object result = invokeMethod(this.getClassName(), this.getMethodName());
    1.38              setAttr("bck2brwsr.fragment", "innerHTML", "");
    1.39              log("Result: " + result);
    1.40 +            log("Time: " + time + " ms");
    1.41              result = encodeURL("" + result);
    1.42 -            log("Sending back: ...?request=" + this.getRequestId() + "&result=" + result);
    1.43              return result;
    1.44          }
    1.45  
    1.46 @@ -340,7 +346,11 @@
    1.47                          if (inst == null) {
    1.48                              inst = c.newInstance();
    1.49                          }
    1.50 +                        double now = getTime();
    1.51                          res = found.invoke(inst);
    1.52 +                        double took = Math.round(getTime() - now);
    1.53 +                        time += took;
    1.54 +                        log("Execution took " + took + " ms");
    1.55                      }
    1.56                  } catch (Throwable ex) {
    1.57                      if (ex instanceof InvocationTargetException) {