From: Dan Vanderkam Date: Tue, 26 Jul 2011 04:49:41 +0000 (-0400) Subject: add timingName option X-Git-Tag: v1.0.0~441 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=7153e001b9878a4bbb04690bfaaaf764c4efa2c7;p=dygraphs.git add timingName option --- diff --git a/dygraph-options-reference.js b/dygraph-options-reference.js index 5bc7f63..74b7bed 100644 --- a/dygraph-options-reference.js +++ b/dygraph-options-reference.js @@ -545,6 +545,12 @@ Dygraph.OPTIONS_REFERENCE = // "labels": ["Data"], "type": "string (URL of CSV or CSV), GViz DataTable or 2D Array", "description": "Sets the data being displayed in the chart. This can only be set when calling updateOptions; it cannot be set from the constructor. For a full description of valid data formats, see the Data Formats page." + }, + "timingName": { + "default": "null", + "labels": [ "Debugging" ], + "type": "string", + "description": "Set this option to log timing information. The value of the option will be logged along with the timimg, so that you can distinguish multiple dygraphs on the same page." } } ; // @@ -573,7 +579,8 @@ Dygraph.OPTIONS_REFERENCE = // 'Overall display', 'Rolling Averages', 'Value display/formatting', - 'Zooming' + 'Zooming', + 'Debugging' ]; var cats = {}; for (var i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true; diff --git a/dygraph.js b/dygraph.js index 555bae4..a1f8c1c 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1881,6 +1881,8 @@ Dygraph.prototype.extremeValues_ = function(series) { * number of axes, rolling averages, etc. */ Dygraph.prototype.predraw_ = function() { + var start = new Date(); + // TODO(danvk): move more computations out of drawGraph_ and into here. this.computeYAxes_(); @@ -1917,6 +1919,8 @@ Dygraph.prototype.predraw_ = function() { * @private */ Dygraph.prototype.drawGraph_ = function(clearSelection) { + var start = new Date(); + if (typeof(clearSelection) === 'undefined') { clearSelection = true; } @@ -2078,6 +2082,13 @@ Dygraph.prototype.drawGraph_ = function(clearSelection) { if (this.attr_("drawCallback") !== null) { this.attr_("drawCallback")(this, is_initial_draw); } + + if (this.attr_("timingName")) { + var end = new Date(); + if (console) { + console.log(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms") + } + } }; /** diff --git a/tests/dygraph-many-points-benchmark.html b/tests/dygraph-many-points-benchmark.html index 4cf7ef5..d1e2a58 100644 --- a/tests/dygraph-many-points-benchmark.html +++ b/tests/dygraph-many-points-benchmark.html @@ -78,7 +78,7 @@ } var rollPeriod = parseInt( document.getElementById('roll_period_input').value); - var opts = {labels: labels, rollPeriod: rollPeriod}; + var opts = {labels: labels, rollPeriod: rollPeriod, timingName: "x"}; var millisecondss = []; for (var i = 0; i < repetitions; i++) { var start = new Date();