4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>Benchmarking for Plots with Many Points
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
10 For production (minified) code, use:
11 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
13 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
17 <p>Plot which can be easily generated with different numbers of points for
18 benchmarking/profiling and improving performance of dygraphs.
</p>
20 <input type=
"radio" id=
"sine" name=
"group1" value=
"sine"
21 onclick=
"clickedRadioButton(this);" checked
> sinusoid function
22 <input type=
"radio" id=
"rand" name=
"group1" value=
"rand"
23 onclick=
"clickedRadioButton(this);"> random points
<br></p>
25 <input type=
"text" id=
"points" size=
"20"></p>
27 <input type=
"text" id=
"series" size=
"20"></p>
28 <p>Roll period (in points):
29 <input type=
"text" id=
"rollPeriod" size=
"20"></p>
31 <input type=
"text" id=
"repetitions" size=
"20"></p>
33 <input type=
"button" value=
"Go!" onclick=
"updatePlot();">
37 <div id=
"message"></div>
38 <div id=
"metrics"></div>
39 <div id=
"metaperformance"></div>
41 <script type=
"text/javascript">
43 var dataType =
"sine";
46 updatePlot = function() {
47 document.getElementById('message').innerHTML =
"";
48 var plotDiv = document.getElementById('plot');
49 plotDiv.innerHTML = 'Redrawing...';
51 parseInt(document.getElementById('points').value);
53 parseInt(document.getElementById('series').value);
55 parseInt(document.getElementById('repetitions').value);
59 var xmax =
2.0 * Math.PI;
61 var delta = (xmax - xmin) / (numPoints -
1);
63 for (var i =
0; i < numPoints; ++i) {
64 var x = xmin + delta * i;
66 for (var j =
0; j < numSeries; j++) {
68 if (dataType ==
"rand") {
69 y = Math.pow(Math.random() - Math.random(),
7);
71 y = Math.sin(x + (j * adj));
78 for (var j =
0; j < numSeries; j++) {
79 labels.push(
"data-set-" + j);
81 var rollPeriod = parseInt(
82 document.getElementById('rollPeriod').value);
83 var opts = {labels: labels, rollPeriod: rollPeriod, timingName:
"x"};
84 var millisecondss = [];
85 for (var i =
0; i < repetitions; i++) {
86 var start = new Date();
87 plot = new Dygraph(plotDiv, data, opts);
89 durations.push([start, end - start]);
90 millisecondss.push(end - start);
92 if (repetitions ==
1) {
93 document.getElementById('message').innerHTML =
94 "completed in " + (end - start) +
" milliseconds.";
97 for (var i =
0; i < millisecondss.length; i++) {
98 avg+=millisecondss[i];
100 avg/=millisecondss.length;
101 document.getElementById('message').innerHTML =
102 "Durations: " + millisecondss +
" Average: " + avg;
105 if (durations.length
> 0) {
106 var start2 = new Date();
108 document.getElementById('metrics'),
111 highlightCircleSize:
4,
112 labels: [
"Date",
"ms" ]
114 var end2 = new Date();
115 document.getElementById(
"metaperformance").innerHTML =
116 "completed in " + (end2 - start2) +
" milliseconds.";
120 clickedRadioButton = function(radiobutton) {
121 dataType = radiobutton.value;
132 // Parse the URL for parameters. Use it to override the values hash.
133 var href = window.location.href;
134 var qmindex = href.indexOf('?');
136 var entries = href.substr(qmindex +
1).split('&');
137 for (var idx =
0; idx < entries.length; idx++) {
138 var entry = entries[idx];
139 var eindex = entry.indexOf('=');
141 values[entry.substr(
0, eindex)] = entry.substr(eindex +
1);
146 var populate = function(name) {
147 document.getElementById(name).value = values[name];
150 var populateRadio = function(name) {
151 var val = values[name];
152 var elem = document.getElementById(val);
159 populate('rollPeriod');
160 populate('repetitions');
161 populateRadio('type');