Updated Branches:
  refs/heads/5.4-js-rewrite 4b5043fb0 -> b4a8eb7cc

Log an info for each page as it is loaded, with assembly time
Change Page.Stats to store a double for number of ms to assemble/load page 
instance
Update Page.Stats after invoking page.loaded()


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b4a8eb7c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b4a8eb7c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b4a8eb7c

Branch: refs/heads/5.4-js-rewrite
Commit: b4a8eb7cc46454602b822e07d12862b31bc5ec1b
Parents: 4b5043f
Author: Howard M. Lewis Ship <[email protected]>
Authored: Thu Nov 8 16:16:46 2012 -0800
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Thu Nov 8 16:16:46 2012 -0800

----------------------------------------------------------------------
 .../tapestry5/corelib/pages/PageCatalog.java       |    9 ++---
 .../internal/pageload/PageLoaderImpl.java          |   25 ++++++++++++++-
 .../apache/tapestry5/internal/structure/Page.java  |    7 ++--
 3 files changed, 32 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b4a8eb7c/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
index a63951b..2be477b 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
@@ -1,4 +1,4 @@
-// Copyright 2011 The Apache Software Foundation
+// Copyright 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -95,8 +95,7 @@ public class PageCatalog
     private Messages messages;
 
     @Property
-    @Retain
-    private BeanModel<Page> model;
+    public static BeanModel<Page> model;
 
     void pageLoaded()
     {
@@ -319,8 +318,8 @@ public class PageCatalog
         return pagesZone.getBody();
     }
 
-    public String formatElapsed(long millis)
+    public String formatElapsed(double millis)
     {
-        return String.format("%,d ms", millis);
+        return String.format("%,.3f ms", millis);
     }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b4a8eb7c/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
index b34628f..f54f42e 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
@@ -42,6 +42,7 @@ import org.apache.tapestry5.runtime.RenderCommand;
 import org.apache.tapestry5.runtime.RenderQueue;
 import org.apache.tapestry5.services.*;
 import org.apache.tapestry5.services.pageload.ComponentResourceSelector;
+import org.slf4j.Logger;
 
 import java.util.Collections;
 import java.util.List;
@@ -145,11 +146,13 @@ public class PageLoaderImpl implements PageLoader, 
ComponentAssemblerSource
 
     private final SymbolSource symbolSource;
 
+    private final Logger logger;
+
     public PageLoaderImpl(ComponentInstantiatorSource instantiatorSource, 
ComponentTemplateSource templateSource,
                           PageElementFactory elementFactory, 
ComponentPageElementResourcesSource resourcesSource,
                           ComponentClassResolver componentClassResolver, 
PersistentFieldManager persistentFieldManager,
                           StringInterner interner, OperationTracker tracker, 
PerthreadManager perThreadManager, Request request,
-                          SymbolSource symbolSource)
+                          SymbolSource symbolSource, Logger logger)
     {
         this.instantiatorSource = instantiatorSource;
         this.templateSource = templateSource;
@@ -162,6 +165,7 @@ public class PageLoaderImpl implements PageLoader, 
ComponentAssemblerSource
         this.perThreadManager = perThreadManager;
         this.request = request;
         this.symbolSource = symbolSource;
+        this.logger = logger;
     }
 
     @PostInjection
@@ -183,6 +187,8 @@ public class PageLoaderImpl implements PageLoader, 
ComponentAssemblerSource
     {
         final String pageClassName = 
componentClassResolver.resolvePageNameToClassName(logicalPageName);
 
+        final long startTime = System.nanoTime();
+
         return tracker.invoke("Constructing instance of page class " + 
pageClassName, new Invokable<Page>()
         {
             public Page invoke()
@@ -201,6 +207,23 @@ public class PageLoaderImpl implements PageLoader, 
ComponentAssemblerSource
 
                 page.loaded();
 
+                long elapsedTime = System.nanoTime() - startTime;
+
+                double elapsedMS = elapsedTime * 10E-7d;
+
+                if (logger.isInfoEnabled())
+                {
+                    logger.info(String.format("Loaded page '%s' (%s) in %.3f 
ms",
+                            logicalPageName, selector.toShortString(), 
elapsedMS));
+                }
+
+                // The rough stats are set by the assembler, and don't include 
the page load time;
+                // so we update them to match.
+
+                Page.Stats roughStats = page.getStats();
+
+                page.setStats(new Page.Stats(elapsedMS, 
roughStats.componentCount, roughStats.weight));
+
                 return page;
             }
         });

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b4a8eb7c/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
index 845f0a4..c483849 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
@@ -50,10 +50,11 @@ public interface Page extends PageLifecycleCallbackHub
     {
         /**
          * Time, in milliseconds, to construct the page. This includes time to 
construct components inside the page,
-         * as well as hooking everything together. You'll often see that the 
first page is expensive to construct,
+         * as well as hooking everything together, and includes the execution 
of {@link org.apache.tapestry5.internal.structure.Page#loaded()}.
+         * You'll often see that the first page is expensive to construct,
          * and later pages that use a similar mix of components are very cheap.
          */
-        public final long assemblyTime;
+        public final double assemblyTime;
 
         /**
          * The total number of components in the page, including the root 
component. This does not include the number of mixins.
@@ -66,7 +67,7 @@ public interface Page extends PageLifecycleCallbackHub
          */
         public final int weight;
 
-        public Stats(long assemblyTime, int componentCount, int weight)
+        public Stats(double assemblyTime, int componentCount, int weight)
         {
             this.assemblyTime = assemblyTime;
             this.componentCount = componentCount;

Reply via email to