-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
perflineseries-benchmark.js
91 lines (89 loc) · 2.62 KB
/
perflineseries-benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
YUI.add('perflineseries-benchmark', function (Y) {
Y.BenchmarkSuite = new Benchmark.Suite();
var suite = Y.BenchmarkSuite,
container,
graphic,
mockChart,
mockGraph,
xAxis,
yAxis,
dataProvider = Y.GeneratePerfTestDataProvider.getData(),
seriesObject,
seriesKeys = ["expenses", "revenue"];
container = document.createElement('div');
container.style.left = "10px";
container.style.top = "10px";
container.style.width = "600px";
container.style.height = "300px";
container.id = "container";
document.body.appendChild(container);
suite.add("PerfLineSeries", function() {
var i,
key,
series,
len = seriesKeys.length;
seriesObject = {};
for(i = 0; i < len; i = i + 1)
{
key = seriesKeys[i];
series = new Y.LineSeries({
graphOrder: i,
xAxis: xAxis,
yAxis: yAxis,
graph: mockGraph,
xKey: "date",
yKey: key
});
series.render();
seriesObject[key] = series;
}
graphic._redraw();
for(key in seriesObject)
{
if(seriesObject.hasOwnProperty(key))
{
seriesObject[key].destroy(true);
}
}
}, {
onStart: function() {
xAxis = new Y.TimeAxis({
dataProvider: dataProvider,
keys: ["date"],
position: "none"
});
yAxis = new Y.NumericAxis({
dataProvider: dataProvider,
keys: ["expenses", "revenue"],
position: "none"
});
mockGraph = {};
graphic = new Y.Graphic({
render: container
});
mockChart = {};
mockChart.get = function(attr) {
var val = "yuichart";
return val;
};
mockGraph.get = function(attr) {
var val;
switch(attr) {
case "width" :
val = 600;
break;
case "height" :
val = 300;
break;
case "graphic" :
val = graphic;
break;
case "chart" :
val = mockChart;
break;
}
return val;
};
}
});
}, '@VERSION@', {requires: ['charts']});