Commits

Brian Burg committed 30e410c

demo time..

Comments (0)

Files changed (1)

 
 results = [];
 
+timerCb = {};
+
 function stopProbes() {
     if (!probes) return;
 
 			       "pendingData.push(current);");
     activeHandlers.push(cookie);
 
-    var cb = {
+    timerCb = {
 	observe: function(subject, topic, data) {
+	    drawGraph();
 	    probes.asyncQuery("while (pendingData.length) { postMessage(pendingData.pop()); }", 
 			      function(e){ results.push(e.value); });
 	},
     }
 
-    timer.init(cb, 5000, TYPE_REPEATING_SLACK);
+    timer.init(timerCb, 1000, TYPE_REPEATING_SLACK);
 }
 
 function drawGraph() {
         };
     }
 
-    function getGCDurationMarks() {
-	/* TODO: see http://people.iola.dk/olau/flot/examples/visitors.html
-	   to see how to mark portions of the timeline. */
-	return 0;
-    }
-
     function prepareTimelinePlot(dataArr) {
 
 	var heapSizeData = [];
-	var durationSizeData = [];
 	var gcDurationMarks = [];
-
 	var startTime = dataArr[0][0];
 
 	for each (origRec in dataArr) {
-	    rec = origRec;
-	    rec[0] -= startTime;
-	    rec[1] -= startTime;
+	    [gcstart, gcend, heapstart, heapend] = origRec;
+	    gcstart -= startTime;
+	    gcend -= startTime;
 
 	    /* generate heap size over time */
-	    heapSizeData.push([rec[0], rec[2]]);
-	    heapSizeData.push([rec[1], rec[3]]);
-
-	    /* generate scatter plot data of gc duration vs. reclaimed memory. */
-	    durationSizeData.push([rec[1]-rec[0], rec[2]-rec[3]]);
+	    heapSizeData.push([gcstart, heapstart]);
+	    heapSizeData.push([gcend, heapend]);
 
 	    /* generate gc time markings */
-	    gcDurationMarks.push({ xaxis: { from: rec[0], to: rec[0] }, color: '#dde' });
-	    gcDurationMarks.push({ xaxis: { from: rec[0], to: rec[1] }, color: '#eef' });
-	    gcDurationMarks.push({ xaxis: { from: rec[1], to: rec[1] }, color: '#dde' });
+	    gcDurationMarks.push({ xaxis: { from: gcstart, to: gcstart }, color: '#dde' });
+	    gcDurationMarks.push({ xaxis: { from: gcstart, to: gcend }, color: '#eef' });
+	    gcDurationMarks.push({ xaxis: { from: gcend, to: gcend }, color: '#dde' });
 	}
 
 	var options = { yaxes: [ { tickFormatter: format_bytes,
 	return [graphdata, options];
     }
 
-    /* actually plot/draw now */
-    gc1.sort(function(a,b) { return a[0] - b[0]; });
+    /* actually plot/draw now-- if data exists */
+    if (!results.length) return;
 
-    [data, opts, postplot] = prepareTimelinePlot(gc1);
+    results.sort(function(a,b) { return a[0] - b[0]; });
+
+    [data, opts, postplot] = prepareTimelinePlot(results);
     var timelinePlot = $.plot($("#gc-timeline"), data, opts);
     postplot(timelinePlot);
 
     });
 
 
-    [data, opts, postplot] = prepareScatterPlot(gc1);
+    [data, opts, postplot] = prepareScatterPlot(results);
     var scatterplot = $.plot($("#gc-scatterplot"), data, opts);
     postplot(scatterplot);
 
     });
 
 */
+}
 
-    testProbes();
 
-}
+testProbes();