Search in sources :

Example 1 with UicStats

use of com.github.bordertech.wcomponents.monitor.UicStats in project wcomponents by BorderTech.

the class DevToolkit method getUicStats.

/**
 * Retrieves statistics on the active UIContext, in a format suitable for rendering to the UI.
 *
 * @return statistics on the active UIContext.
 */
public String getUicStats() {
    StringWriter writer = new StringWriter();
    PrintWriter printWriter = new PrintWriter(writer);
    UicStats stats = new UicStats(UIContextHolder.getCurrent());
    UicStatsAsHtml.write(printWriter, stats);
    printWriter.close();
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) UicStats(com.github.bordertech.wcomponents.monitor.UicStats) PrintWriter(java.io.PrintWriter)

Example 2 with UicStats

use of com.github.bordertech.wcomponents.monitor.UicStats in project wcomponents by BorderTech.

the class SimplePicker method afterPaint.

/**
 * Override afterPaint in order to paint the UIContext serialization statistics if the profile button has been
 * pressed.
 *
 * @param renderContext the renderContext to send output to.
 */
@Override
protected void afterPaint(final RenderContext renderContext) {
    super.afterPaint(renderContext);
    if (profileBtn.isPressed()) {
        // UIC serialization stats
        UicStats stats = new UicStats(UIContextHolder.getCurrent());
        WComponent currentComp = this.getCurrentComponent();
        if (currentComp != null) {
            stats.analyseWC(currentComp);
        }
        if (renderContext instanceof WebXmlRenderContext) {
            PrintWriter writer = ((WebXmlRenderContext) renderContext).getWriter();
            writer.println("<hr />");
            writer.println("<h2>Serialization Profile of UIC</h2>");
            UicStatsAsHtml.write(writer, stats);
            if (currentComp != null) {
                writer.println("<hr />");
                writer.println("<h2>ObjectProfiler - " + currentComp + "</h2>");
                writer.println("<pre>");
                try {
                    writer.println(ObjectGraphDump.dump(currentComp).toFlatSummary());
                } catch (Exception e) {
                    LOG.error("Failed to dump component", e);
                }
                writer.println("</pre>");
            }
        }
    }
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WebXmlRenderContext(com.github.bordertech.wcomponents.servlet.WebXmlRenderContext) UicStats(com.github.bordertech.wcomponents.monitor.UicStats) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PrintWriter(java.io.PrintWriter)

Aggregations

UicStats (com.github.bordertech.wcomponents.monitor.UicStats)2 PrintWriter (java.io.PrintWriter)2 WComponent (com.github.bordertech.wcomponents.WComponent)1 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1