From: David ‘Bombe’ Roden Date: Wed, 10 Nov 2010 14:30:40 +0000 (+0100) Subject: Show template rendering time in milliseconds. X-Git-Tag: 0.2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b32a06c6f1b42c17e059b1a5da7069b0ca145996;p=Sone.git Show template rendering time in milliseconds. --- diff --git a/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java index 761e89b..a6373fc 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java @@ -20,8 +20,11 @@ package net.pterodactylus.sone.web.page; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; +import java.util.logging.Level; +import java.util.logging.Logger; import net.pterodactylus.sone.web.page.Page.Request.Method; +import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.template.Template; import freenet.clients.http.LinkEnabledCallback; import freenet.clients.http.PageMaker; @@ -36,6 +39,9 @@ import freenet.l10n.BaseL10n; */ public class TemplatePage implements Page, LinkEnabledCallback { + /** The logger. */ + private static final Logger logger = Logging.getLogger(TemplatePage.class); + /** The path of the page. */ private final String path; @@ -111,7 +117,10 @@ public class TemplatePage implements Page, LinkEnabledCallback { } try { + long start = System.nanoTime(); processTemplate(request, template); + long finish = System.nanoTime(); + logger.log(Level.FINEST, "Template was rendered in " + ((finish - start) / 1000) / 1000.0 + "ms."); } catch (RedirectException re1) { return new RedirectResponse(re1.getTarget()); }