List of usage examples for jdk.nashorn.internal.runtime Context getContext
public static Context getContext()
From source file:net.orzo.lib.Lib.java
License:Apache License
/** * Measures the execution time of the provided function. Please note that in * case of asynchronous code you may not obtain the value you have been * expecting.// w w w. j a v a 2 s. co m * * @param function * @return time in milliseconds */ public long measureTime(ScriptFunction function) { long startTime = System.currentTimeMillis(); MethodHandle mh = function.getBoundInvokeHandle(Context.getContext()); try { mh.invoke(); } catch (Throwable e) { throw new LibException(e); } return System.currentTimeMillis() - startTime; }