[jboss-cvs] JBoss Profiler SVN: r490 - branches/JBossProfiler2/src/main/org/jboss/profiler/shared.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 24 09:19:58 EDT 2008


Author: jesper.pedersen
Date: 2008-10-24 09:19:58 -0400 (Fri, 24 Oct 2008)
New Revision: 490

Modified:
   branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java
Log:
Make NetTime and TotalTime transient

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java	2008-10-24 12:35:43 UTC (rev 489)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/FrameInfo.java	2008-10-24 13:19:58 UTC (rev 490)
@@ -35,7 +35,7 @@
 public class FrameInfo implements Serializable {
 
   /** Serial version UID */
-  static final long serialVersionUID = 8251940154906731467L;
+  static final long serialVersionUID = 5886070827318986209L;
 
   /** The method */
   private MethodInfo method;
@@ -46,9 +46,6 @@
   /** The child frames */
   private List<FrameInfo> children;
   
-  /** The net time */
-  private long netTime;
-
   /** The count */
   private long count;
 
@@ -61,6 +58,12 @@
   /** Child map */
   private transient Map<MethodInfo, Integer> childMap;
 
+  /** The net time */
+  private transient long netTime;
+
+  /** The total time */
+  private transient long totalTime;
+
   /** The last start time */
   private transient long lastStartTime;
 
@@ -76,11 +79,13 @@
     this.method = method;
     this.parent = parent;
     this.children = null;
-    this.netTime = -1;
     this.count = 0;
     this.time = 0;
     this.waitTime = 0;
+
     this.childMap = null;
+    this.netTime = -1;
+    this.totalTime = -1;
     this.lastStartTime = 0;
     this.lastWaitStartTime = 0;
     
@@ -118,7 +123,7 @@
    * @return The net time
    */
   public long getNetTime() {
-    if (netTime < 0) {
+    if (netTime <= 0) {
       computeNetTime();
     }
 
@@ -223,12 +228,8 @@
    * @return The total time
    */
   public long getTotalTime() {
-    long totalTime = getNetTime();
-
-    if (getChildren() != null) {
-      for (FrameInfo f : getChildren()) {
-        totalTime += f.getTotalTime();
-      }
+    if (totalTime <= 0) {
+      computeTotalTime();
     }
 
     return totalTime;
@@ -242,15 +243,14 @@
       setEndTime(System.nanoTime());
     }
 
-    synchronized (children) {
-      List<FrameInfo> l = getChildren();
-      if (l != null) {
-        for (FrameInfo child: l) {
+    if (getChildren() != null) {
+      synchronized (children) {
+        for (FrameInfo child: children) {
           child.close();
         }
+
+        childMap = null;
       }
-
-      childMap = null;
     }
   }
 
@@ -275,6 +275,20 @@
   }
 
   /**
+   * Compute the total time
+   */
+  private void computeTotalTime() {
+    totalTime = getNetTime();
+
+    List<FrameInfo> l = getChildren();
+    if (l != null) {
+      for (FrameInfo child: l) {
+        totalTime += child.getTotalTime();
+      }
+    }
+  }
+
+  /**
    * Init children
    */
   private void initChildren() {
@@ -292,14 +306,15 @@
    * @param fi The child
    */
   private void addChild(MethodInfo mi, FrameInfo fi) {
+    if (children == null || childMap == null) {
+      initChildren();
+    }
+
     synchronized (children) {
-      if (children == null || childMap == null) {
-        initChildren();
-      }
-
       children.add(fi);
       childMap.put(mi, Integer.valueOf(children.size() - 1));
       netTime = -1;
+      totalTime = -1;
     }
   }
 }




More information about the jboss-cvs-commits mailing list