/** * @VisibleForTesting */ void after(final StopWatch stopWatch) { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * @VisibleForTesting */ void after(final StopWatch stopWatch) { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
@Override public void onProcessingComplete() { stopWatchIfRunning(); if (getWatch().getTaskCount() > 0) { LOG.debug(getWatch().prettyPrint()); } }
@Override public void onProcessingComplete() { stopWatchIfRunning(); if (getWatch().getTaskCount() > 0) { LOG.debug(getWatch().prettyPrint()); } }
/** * {@inheritDoc} */ @Override public synchronized WroModel create() { final StopWatch stopWatch = new StopWatch("Create Wro Model from Groovy"); try { stopWatch.start("createModel"); final Type type = new TypeToken<WroModel>() {}.getType(); final InputStream is = getModelResourceAsStream(); if (is == null) { throw new WroRuntimeException("Invalid model stream provided!"); } final WroModel model = new Gson().fromJson(new InputStreamReader(getModelResourceAsStream()), type); LOG.debug("json model: {}", model); if (model == null) { throw new WroRuntimeException("Invalid content provided, cannot build model!"); } return model; } catch (final Exception e) { throw new WroRuntimeException("Invalid model found!", e); } 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()); } } }
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 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 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 * 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); }
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()); } }
@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()); } }
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()); } }