Debian Codegraph @

dojox/grid/tests/test_treegrid_performance.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <title>dojox.grid.TreeGrid Performance Tests</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
6 <style type="text/css">
7 @import "../../../dojo/resources/dojo.css";
8 @import "../resources/Grid.css";
9 @import "../resources/tundraGrid.css";
10 .grid {
11 width: 70em;
12 height: 15em;
13 }
14 </style>
15 <script type="text/javascript" src="../../../dojo/dojo.js"
16 data-dojo-config="isDebug:false, parseOnLoad: false"></script>
17 <script type="text/javascript">
18 dojo.require("dojox.grid.DataGrid");
19 dojo.require("dojox.grid.TreeGrid");
20 dojo.require("dojo.data.ItemFileWriteStore");
21 dojo.require("dojo.parser");
22
23 // Set to true in order to kick off profiling startup and resizes in
24 // firebug
25 var doProfiling = false;
26 var profileTime = 100;
27
28 var resizeAndProfile = function(grid){
29 var d = new dojo.Deferred();
30 if(doProfiling){
31 console.profile("Resize " + grid.id);
32 window.profiling = true;
33 window.profid = grid.id;
34 }
35 grid.resize();
36 if(doProfiling){
37 window.setTimeout(function(){
38 console.profileEnd();
39 delete window.profiling;
40 d.callback(true);
41 }, profileTime);
42 }else{
43 d.callback(true);
44 }
45 return d;
46 }
47
48 var parseAndProfile = function(parseContainer, idx){
49 var d = new dojo.Deferred();
50 if(doProfiling){
51 console.profile("Startup/Creation " + idx);
52 window.profiling = true;
53 window.profid = "idx_"+idx;
54 }
55 dojo.parser.parse(parseContainer);
56 if(doProfiling){
57 window.setTimeout(function(){
58 console.profileEnd();
59 delete window.profiling;
60 d.callback(true);
61 }, profileTime);
62 }else{
63 d.callback(true);
64 }
65 return d;
66 }
67
68 dojo.addOnLoad(function(){
69 dojo.parser.parse(dojo.query(".testTitle")[0]);
70 dijit._TemplatedMixin.getCachedTemplate(dojo.moduleUrl("dojox.grid","resources/_Grid.html"));
71 dijit._TemplatedMixin.getCachedTemplate(dojo.moduleUrl("dojox.grid", "resources/Expando.html"));
72 dijit._TemplatedMixin.getCachedTemplate(dojo.moduleUrl("dojox.grid","resources/View.html"));
73 jsonStore.fetch({onComplete: function(){
74 doProfiling = dojo.isMoz && doProfiling;
75 dojo.connect(window, "onresize", function(){
76 var grids = dojo.filter(dojo.query(".grid").map(dijit.byNode), function(w){ return w && w.resize; });
77 var i = 0;
78 var cb = function(){
79 var g = grids[i];
80 i++;
81 if(g){
82 d = resizeAndProfile(g);
83 d.addCallback(cb);
84 }
85 };
86 cb();
87 });
88 var containers = dojo.query(".parseContainer");
89 var idx = 0;
90 var pcb = function(){
91 var cont = containers[idx];
92 idx++;
93 if(cont){
94 d = parseAndProfile(cont, idx - 1);
95 d.addCallback(pcb);
96 }
97 };
98 pcb();
99 }});
100 });
101
102 function formatTime(value, rowIdx){
103 var hrs = Math.floor(value / 60) + "";
104 var mins = (value % 60) + "";
105 while (hrs.length < 2){
106 hrs = "0" + hrs;
107 }
108 while (mins.length < 2){
109 mins = "0" + mins;
110 }
111 return hrs + ":" + mins;
112 }
113
114 function summaryFormatter(value, rowIdx, cell, sing, plur){
115 var str;
116 if(rowIdx >= 0){
117 return value;
118 }
119 if(rowIdx == -1){
120 str = "Total (${numItems} ${displayName}):";
121 }else{
122 str = "${numItems} ${displayName}";
123 }
124 return dojo.string.substitute(str, {numItems: value,
125 displayName: (value == 1) ? sing : plur});
126 }
127 function quarterSummary(value, rowIdx){
128 return summaryFormatter(value, rowIdx, this, "Quarter", "Quarters");
129 }
130 function gameSummary(value, rowIdx){
131 return summaryFormatter(value, rowIdx, this, "Game", "Games");
132 }
133 function seasonSummary(value, rowIdx){
134 return summaryFormatter(value, rowIdx, this, "Season", "Seasons");
135 }
136 </script>
137 </head>
138 <body class="tundra">
139 <h1 class="testTitle">
140 Test: dojox.tests.grid.TreeGrid Performance
141 <span dojoType="dojo.data.ItemFileWriteStore"
142 data-dojo-id="jsonStore" url="support/gamedata.json">
143 </span>
144 </h1>
145
146 <h4 class="testSubtitle">dojox.grid.DataGrid (For reference)</h4>
147 <div class="parseContainer">
148 <table dojoType="dojox.grid.DataGrid" class="grid" style="height: 15em;width: 100%;"
149 store="jsonStore" rowsPerPage="50" query="{label:'Quarter *'}" queryOptions="{deep: true}" rowSelector="false">
150 <thead>
151 <tr>
152 <th field="label" relWidth="2" formatter="quarterSummary">Quarter</th>
153 <th field="pts" relWidth="1">Points</th>
154 <th field="reb" relWidth="1">Rebounds</th>
155 <th field="ast" relWidth="1">Assists</th>
156 <th field="tp" relWidth="1" formatter="formatTime">Time Played</th>
157 </tr>
158 </thead>
159 </table>
160 </div>
161 <h4 class="testSubtitle">dojox.grid.TreeGrid Large 4-Level</h4>
162 <div class="parseContainer">
163 <table dojoType="dojox.grid.TreeGrid" class="grid" style="height: 15em;width: 100%;"
164 store="jsonStore" rowsPerPage="20" rowSelector="false">
165 <thead>
166 <tr>
167 <th field="label" relWidth="2">Player</th>
168 <th field="seasns" aggregate="sum" itemAggregates="numSeasons">
169 <table>
170 <thead>
171 <tr>
172 <th field="label" relWidth="2" formatter="seasonSummary">Season</th>
173 <th field="games" aggregate="sum" itemAggregates="numGames">
174 <table>
175 <thead>
176 <tr>
177 <th field="label" relWidth="2" formatter="gameSummary">Game</th>
178 <th field="qtrs" aggregate="sum" itemAggregates="numQtrs,totPts,totReb,totAst,totTP">
179 <table>
180 <thead>
181 <tr>
182 <th field="label" relWidth="2" formatter="quarterSummary">Quarter</th>
183 <th field="pts" relWidth="1">Points</th>
184 <th field="reb" relWidth="1">Rebounds</th>
185 <th field="ast" relWidth="1">Assists</th>
186 <th field="tp" relWidth="1" formatter="formatTime">Time Played</th>
187 </tr>
188 </thead>
189 </table>
190 </th>
191 </tr>
192 </thead>
193 </table>
194 </th>
195 </tr>
196 </thead>
197 </table>
198 </th>
199 </tr>
200 </thead>
201 </table>
202 </div>
203 </body>
204 </html>
205