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" name=
"plot_group1" value=
"sine" onclick=
"clickedRadioButton(this);" checked
> sinusoid function
21 <input type=
"radio" name=
"plot_group1" value=
"rand" onclick=
"clickedRadioButton(this);"> random points
<br></p>
23 <input type=
"text" id=
"num_points_input" size=
"20"></p>
25 <input type=
"text" id=
"num_series_input" size=
"20"></p>
26 <p>Roll period (in points):
27 <input type=
"text" id=
"roll_period_input" size=
"20"></p>
29 <input type=
"text" id=
"repetitions" size=
"20"></p>
31 <input type=
"button" value=
"Go!" onclick=
"updatePlot();">
35 <div id=
"message"></div>
36 <div id=
"metrics"></div>
37 <div id=
"metaperformance"></div>
39 <script type=
"text/javascript">
41 var dataType =
"sine";
44 updatePlot = function() {
45 document.getElementById('message').innerHTML =
"";
46 var plotDiv = document.getElementById('plot');
47 plotDiv.innerHTML = 'Redrawing...';
49 parseInt(document.getElementById('num_points_input').value);
51 parseInt(document.getElementById('num_series_input').value);
53 parseInt(document.getElementById('repetitions').value);
57 var xmax =
2.0 * Math.PI;
59 var delta = (xmax - xmin) / (numPoints -
1);
61 for (var i =
0; i < numPoints; ++i) {
62 var x = xmin + delta * i;
64 for (var j =
0; j < numSeries; j++) {
66 if (dataType ==
"rand") {
67 y = Math.pow(Math.random() - Math.random(),
7);
69 y = Math.sin(x + (j * adj));
76 for (var j =
0; j < numSeries; j++) {
77 labels.push(
"data-set-" + j);
79 var rollPeriod = parseInt(
80 document.getElementById('roll_period_input').value);
81 var opts = {labels: labels, rollPeriod: rollPeriod, timingName:
"x"};
82 var millisecondss = [];
83 for (var i =
0; i < repetitions; i++) {
84 var start = new Date();
85 plot = new Dygraph(plotDiv, data, opts);
87 durations.push([start, end - start]);
88 millisecondss.push(end - start);
90 if (repetitions ==
1) {
91 document.getElementById('message').innerHTML =
92 "completed in " + (end - start) +
" milliseconds.";
95 for (var i =
0; i < millisecondss.length; i++) {
96 avg+=millisecondss[i];
98 avg/=millisecondss.length;
99 document.getElementById('message').innerHTML =
100 "Durations: " + millisecondss +
" Average: " + avg;
103 if (durations.length
> 0) {
104 var start2 = new Date();
106 document.getElementById('metrics'),
109 highlightCircleSize:
4,
110 labels: [
"Date",
"ms" ]
112 var end2 = new Date();
113 document.getElementById(
"metaperformance").innerHTML =
114 "completed in " + (end2 - start2) +
" milliseconds.";
118 clickedRadioButton = function(radiobutton) {
119 dataType = radiobutton.value;
123 document.getElementById('num_points_input').value = '
100';
124 document.getElementById('num_series_input').value = '
1';
125 document.getElementById('roll_period_input').value = '
1';
126 document.getElementById('repetitions').value = '
1';