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()); } } }
/** * Return a short description of the total running time. */ public String shortSummary() { return "StopWatch '" + this.id + "': running time (millis) = " + getTotalTimeMillis(); }
/** * @VisibleForTesting */ void after(final StopWatch stopWatch) { stopWatch.stop(); LOG.debug(stopWatch.prettyPrint()); } }
/** * Start an unnamed task. The results are undefined if {@link #stop()} or timing methods are called without invoking * this method. * * @see #stop() */ public void start() throws IllegalStateException { start(""); }
@Override public void onProcessingComplete() { stopWatchIfRunning(); if (getWatch().getTaskCount() > 0) { LOG.debug(getWatch().prettyPrint()); } }
/** * {@inheritDoc} */ @Override public void process(final Resource resource, final Reader reader, final Writer writer) throws IOException { StopWatch stopWatch = null; if (isDebug()) { stopWatch = new StopWatch(); before(stopWatch); } try { super.process(resource, reader, writer); } finally { if (isDebug()) { after(stopWatch); } } }
/** * Return a string with a table describing all tasks performed. For custom reporting, call getTaskInfo() and use the * task info directly. */ public String prettyPrint() { final StringBuffer sb = new StringBuffer(shortSummary()); sb.append('\n'); if (!this.keepTaskList) { sb.append("No task info kept"); } else { final TaskInfo[] tasks = getTaskInfo(); sb.append("-----------------------------------------\n"); sb.append("ms % Task name\n"); sb.append("-----------------------------------------\n"); final NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumIntegerDigits(5); nf.setGroupingUsed(false); final NumberFormat pf = NumberFormat.getPercentInstance(); pf.setMinimumIntegerDigits(3); pf.setGroupingUsed(false); for (final TaskInfo task : tasks) { sb.append(nf.format(task.getTimeMillis()) + " "); final double totalTimeSeconds = getTotalTimeSeconds(); final double percentage = totalTimeSeconds == 0 ? 0 : task.getTimeSeconds() / totalTimeSeconds; sb.append(pf.format(percentage) + " "); sb.append(task.getTaskName() + "\n"); } } return sb.toString(); }
/** * Start an unnamed task. The results are undefined if {@link #stop()} or timing methods are called without invoking * this method. * * @see #stop() */ public void start() throws IllegalStateException { start(""); }
/** * @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()); } }
/** * {@inheritDoc} */ @Override public void process(final Resource resource, final Reader reader, final Writer writer) throws IOException { StopWatch stopWatch = null; if (isDebug()) { stopWatch = new StopWatch(); before(stopWatch); } try { super.process(resource, reader, writer); } finally { if (isDebug()) { after(stopWatch); } } }
/** * Return a string with a table describing all tasks performed. For custom reporting, call getTaskInfo() and use the * task info directly. */ public String prettyPrint() { final StringBuffer sb = new StringBuffer(shortSummary()); sb.append('\n'); if (!this.keepTaskList) { sb.append("No task info kept"); } else { final TaskInfo[] tasks = getTaskInfo(); sb.append("-----------------------------------------\n"); sb.append("ms % Task name\n"); sb.append("-----------------------------------------\n"); final NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMinimumIntegerDigits(5); nf.setGroupingUsed(false); final NumberFormat pf = NumberFormat.getPercentInstance(); pf.setMinimumIntegerDigits(3); pf.setGroupingUsed(false); for (final TaskInfo task : tasks) { sb.append(nf.format(task.getTimeMillis()) + " "); final double totalTimeSeconds = getTotalTimeSeconds(); final double percentage = totalTimeSeconds == 0 ? 0 : task.getTimeSeconds() / totalTimeSeconds; sb.append(pf.format(percentage) + " "); sb.append(task.getTaskName() + "\n"); } } return sb.toString(); }
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()); } } }
/** * @VisibleForTesting */ void before(final StopWatch stopWatch) { stopWatch.start("Using " + this.toString()); }
/** * Return a short description of the total running time. */ public String shortSummary() { return "StopWatch '" + this.id + "': running time (millis) = " + getTotalTimeMillis(); }
/** * @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()); } }
/** * @VisibleForTesting */ void before(final StopWatch stopWatch) { stopWatch.start("Using " + this.toString()); }
/** * @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()); } } }