Commits

Brian Burg  committed 5b779f9

fix sorted value of data records

  • Participants
  • Parent commits 97db53a

Comments (0)

Files changed (1)

File addon/aboutgc.js

     if (!probes) return;
 
     /* init data stream */
-    probes.asyncQuery("pendingData = [];", function(e){});
+    probes.asyncQuery("pendingData = [];" + 
+		      "HEAP_RESIZE_INTERVAL = 500.0;" +  // minimum MS between posted events
+		      "lastRecTime = 0;"
+		      , function(e){});
     var cookie;
 
     cookie = probes.addHandler(probes.COMPARTMENT_GC_DID_START,
 			       "using(env.currentTimeMS);" +
 			       "using(runtime.gcBytes);",
-			       "current = {type: 'GC_COMPARTMENT', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ]};");
+			       "current = {type: 'GC_COMPARTMENT', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ], sortValue: env.currentTimeMS };");
     activeHandlers.push(cookie);
 
     cookie = probes.addHandler(probes.GLOBAL_GC_DID_START,
 			       "using(env.currentTimeMS);" +
 			       "using(runtime.gcBytes);",
-			       "current = {type: 'GC_GLOBAL', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ]};");
+			       "current = {type: 'GC_GLOBAL', data: [env.currentTimeMS, 0, runtime.gcBytes, 0, ], sortValue: env.currentTimeMS };");
+    activeHandlers.push(cookie);
+
+    cookie = probes.addHandler(probes.JS_WILL_RESIZE_HEAP,
+			       "using(env.currentTimeMS);" +
+			       "using(oldSize);" +
+			       "using(newSize);",
+			       "if ((env.currentTimeMS - lastRecTime) > HEAP_RESIZE_INTERVAL) {" +
+			       "  lastRecTime = env.currentTimeMS;" +
+			       "  pendingData.push({type: 'HEAP_RESIZE', sortValue: env.currentTimeMS, data: [env.currentTimeMS, oldSize, newSize]});" +
+			       "}");
     activeHandlers.push(cookie);
 
     cookie = probes.addHandler(probes.COMPARTMENT_GC_WILL_END,
 	    case "HEAP_RESIZE":
 		[time, oldSize, newSize] = origRec.data;
 		time -= startTime;
-		
+
 		heapSizeData.push([time, oldSize]);
 		heapSizeData.push([time, newSize]);
 		break;
     /* actually plot/draw now-- if data exists */
     if (!results.length) return;
 
-    results.sort(function(a,b) { return a[0] - b[0]; });
+    results.sort(function(a,b) { return a.sortValue - b.sortValue; });
 
     [data, opts, postplot] = prepareTimelinePlot(results);
     var timelinePlot = $.plot($("#gc-timeline"), data, opts);