/** * @VisibleForTesting */ void after(final StopWatch stopWatch) { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * @VisibleForTesting */ void after(final StopWatch stopWatch) { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * Safe way to stop the watch. This method will check if it is running - in order to avoid {@link IllegalStateException}. */ private void stopWatchIfRunning() { if (getWatch().isRunning()) { getWatch().stop(); } } }
/** * Safe way to stop the watch. This method will check if it is running - in order to avoid {@link IllegalStateException}. */ private void stopWatchIfRunning() { if (getWatch().isRunning()) { getWatch().stop(); } } }
public String unpack(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("json.unpack"); try { final String execute = "JSON.stringify(CJSON.parse(" + WroUtil.toJSMultiLineString(data) + "));"; final Object result = builder.evaluate(execute, "unpack"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
public String unpack(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("json.unpack"); try { final String execute = "JSON.stringify(CJSON.parse(" + WroUtil.toJSMultiLineString(data) + "));"; final Object result = builder.evaluate(execute, "unpack"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
/** * @param data css content to process. * @return processed css content. */ public String pack(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("cjson.pack"); try { final String execute = "CJSON.stringify(JSON.parse(" + WroUtil.toJSMultiLineString(data) + "));"; final Object result = builder.evaluate(execute, "pack"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * @param data css content to process. * @return processed css content. */ public String less(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("lessify"); try { final String execute = "lessIt(" + WroUtil.toJSMultiLineString(data) + ");"; final Object result = builder.evaluate(execute, "lessIt"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
/** * @param data css content to process. * @return processed css content. */ public String process(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("sass rendering"); try { // replace tabs with spaces, since the script doesn't handle well tabs (throws exception). // dataWithoutTabs = data; final String execute = "exports.render(" + WroUtil.toJSMultiLineString(data) + ");"; final Object result = builder.evaluate(execute, "sassRender"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
/** * @param data css content to process. * @return processed css content. */ public String less(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("lessify"); try { final String execute = "lessIt(" + WroUtil.toJSMultiLineString(data) + ");"; final Object result = builder.evaluate(execute, "lessIt"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
/** * @param data css content to process. * @return processed css content. */ public String pack(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("cjson.pack"); try { final String execute = "CJSON.stringify(JSON.parse(" + WroUtil.toJSMultiLineString(data) + "));"; final Object result = builder.evaluate(execute, "pack"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * @param data css content to process. * @return processed css content. */ public String process(final String data) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("sass rendering"); try { // replace tabs with spaces, since the script doesn't handle well tabs (throws exception). // dataWithoutTabs = data; final String execute = "exports.render(" + WroUtil.toJSMultiLineString(data) + ");"; final Object result = builder.evaluate(execute, "sassRender"); return String.valueOf(result); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } } }
/** * @param data * js content to process. * @return packed js content. */ public String pack(final String data) throws IOException { final StopWatch watch = new StopWatch(); watch.start("init"); final RhinoScriptBuilder builder = initScriptBuilder(); watch.stop(); watch.start("pack"); final String packIt = buildPackScript(WroUtil.toJSMultiLineString(data)); final Object result = builder.evaluate(packIt, "packerIt"); watch.stop(); LOG.debug(watch.prettyPrint()); return String.valueOf(result); }
/** * @param data * js content to process. * @return packed js content. */ public String pack(final String data) throws IOException { final StopWatch watch = new StopWatch(); watch.start("init"); final RhinoScriptBuilder builder = initScriptBuilder(); watch.stop(); watch.start("pack"); final String packIt = buildPackScript(WroUtil.toJSMultiLineString(data)); final Object result = builder.evaluate(packIt, "packerIt"); watch.stop(); LOG.debug(watch.prettyPrint()); return String.valueOf(result); }
/** * @param data * js content to process. * @return packed js content. */ public String process(final String filename, final String code) throws IOException { final StopWatch watch = new StopWatch(); watch.start("init " + filename); final RhinoScriptBuilder builder = initScriptBuilder(); watch.stop(); final String originalCode = WroUtil.toJSMultiLineString(code); // TODO handle reservedNames final String optionsAsJson = createOptionsAsJson(); Validate.notNull(optionsAsJson); final String scriptAsString = String.format(getInvokeScript(), originalCode, optionsAsJson); watch.start(uglify ? "uglify" : "beautify"); final Object result = builder.evaluate(scriptAsString, "uglifyIt"); watch.stop(); LOG.debug(watch.prettyPrint()); return String.valueOf(result); }
public String unpack(final String rawData) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("json.hunpack"); final boolean isEnclosedInDoubleArray = isEnclosedInDoubleArray(rawData); String data = rawData; if (!isEnclosedInDoubleArray) { data = "[" + data + "]"; } try { final String execute = "JSON.stringify(JSON.hunpack(eval(" + WroUtil.toJSMultiLineString(data) + ")));"; final Object result = builder.evaluate(execute, "unpack"); String resultAsString = String.valueOf(result); if (!isEnclosedInDoubleArray) { //remove [] characters in which the json is enclosed resultAsString = removeEnclosedArray(resultAsString); } return resultAsString; } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
public String compile(final String typeScript) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("compile"); try { final String execute = getCompilationCommand(typeScript); final NativeObject compilationResult = (NativeObject) builder.evaluate(execute, "compile"); final NativeArray errors = (NativeArray) compilationResult.get(PARAM_ERRORS); if (errors.size() > 0) { throwCompilationError(errors); } return compilationResult.get(PARAM_SOURCE).toString(); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
public String compile(final String typeScript) { final StopWatch stopWatch = new StopWatch(); stopWatch.start("initContext"); final RhinoScriptBuilder builder = initScriptBuilder(); stopWatch.stop(); stopWatch.start("compile"); try { final String execute = getCompilationCommand(typeScript); final NativeObject compilationResult = (NativeObject) builder.evaluate(execute, "compile"); final NativeArray errors = (NativeArray) compilationResult.get(PARAM_ERRORS); if (errors.size() > 0) { throwCompilationError(errors); } return compilationResult.get(PARAM_SOURCE).toString(); } finally { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
@Override protected WroModel initialize() { callbackRegistry.onBeforeModelCreated(); final StopWatch watch = new StopWatch("Create Model"); watch.start("createModel"); WroModel model = null; try { final WroModelFactory modelFactory = decorate(getDecoratedObject()); injector.inject(modelFactory); model = modelFactory.create(); return model; } finally { authorizeModelResources(model); callbackRegistry.onAfterModelCreated(); watch.stop(); LOG.debug(watch.prettyPrint()); } }
@Override protected WroModel initialize() { callbackRegistry.onBeforeModelCreated(); final StopWatch watch = new StopWatch("Create Model"); watch.start("createModel"); WroModel model = null; try { final WroModelFactory modelFactory = decorate(getDecoratedObject()); injector.inject(modelFactory); model = modelFactory.create(); return model; } finally { authorizeModelResources(model); callbackRegistry.onAfterModelCreated(); watch.stop(); LOG.debug(watch.prettyPrint()); } }