launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java
changeset 1860 4ce38f21f4cd
parent 1827 f07753959dcf
child 1908 4f4554f69892
     1.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Sun Apr 26 10:58:52 2015 +0300
     1.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/impl/Console.java	Tue Jan 26 04:36:23 2016 +0100
     1.3 @@ -53,6 +53,9 @@
     1.4          "elem[attr] = value;")
     1.5      private static native void setAttr(Object id, String attr, Object value);
     1.6      
     1.7 +    @net.java.html.js.JavaScriptBody(args = {}, body = "return new Date().getTime()")
     1.8 +    private static native double getTime();
     1.9 +
    1.10      @net.java.html.js.JavaScriptBody(args = {  }, body = 
    1.11          "var a = document.createElement('a');"
    1.12        + "a.innerHTML = 'Cancel: closing in 10s...';\n"
    1.13 @@ -180,9 +183,11 @@
    1.14                      log("Processing \"" + arr[0] + "\" for " + retries + " time");
    1.15                  }
    1.16                  Object result = retries++ >= 100 ? "java.lang.InterruptedException:timeout(" + retries + ")" : c.runTest();
    1.17 +                String reply = "?request=" + c.getRequestId() + "&time=" + c.time + "&result=" + result;
    1.18 +                log("Sending back: ..." + reply);
    1.19                  finishTest(c, result);
    1.20                  
    1.21 -                String u = url + "?request=" + c.getRequestId() + "&result=" + result;
    1.22 +                String u = url + reply;
    1.23                  new Request(url, u);
    1.24              } catch (Exception ex) {
    1.25                  if (ex instanceof InterruptedException) {
    1.26 @@ -285,6 +290,7 @@
    1.27      private static final class Case {
    1.28          private final Object data;
    1.29          private Object inst;
    1.30 +        private double time;
    1.31  
    1.32          private Case(Object data) {
    1.33              this.data = data;
    1.34 @@ -332,7 +338,6 @@
    1.35              setAttr("bck2brwsr.fragment", "innerHTML", "");
    1.36              log("Result: " + result);
    1.37              result = encodeURL("" + result);
    1.38 -            log("Sending back: ...?request=" + this.getRequestId() + "&result=" + result);
    1.39              return result;
    1.40          }
    1.41  
    1.42 @@ -350,14 +355,19 @@
    1.43              Object res;
    1.44              if (found != null) {
    1.45                  try {
    1.46 +                    double now;
    1.47                      if ((found.getModifiers() & Modifier.STATIC) != 0) {
    1.48 +                        now = getTime();
    1.49                          res = found.invoke(null);
    1.50                      } else {
    1.51                          if (inst == null) {
    1.52                              inst = c.newInstance();
    1.53                          }
    1.54 +                        now = getTime();
    1.55                          res = found.invoke(inst);
    1.56                      }
    1.57 +                    double took = Math.round((float)(getTime() - now));
    1.58 +                    time += took;
    1.59                  } catch (Throwable ex) {
    1.60                      if (ex instanceof InvocationTargetException) {
    1.61                          ex = ((InvocationTargetException) ex).getTargetException();