Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 | 2 |
| 3 <!-- | 3 <!-- |
| 4 Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 4 Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 5 Use of this source code is governed by a BSD-style license that can be | 5 Use of this source code is governed by a BSD-style license that can be |
| 6 found in the LICENSE file. | 6 found in the LICENSE file. |
| 7 --> | 7 --> |
| 8 | 8 |
| 9 <!-- | 9 <!-- |
| 10 A brief note on terminology as used here: a "graph" is a plotted screenful | 10 A brief note on terminology as used here: a "graph" is a plotted screenful |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 var row = jsonToJs(rows[i]); | 183 var row = jsonToJs(rows[i]); |
| 184 var traces = row['traces']; | 184 var traces = row['traces']; |
| 185 var revision = parseInt(row['rev']); | 185 var revision = parseInt(row['rev']); |
| 186 graphData[revision] = traces; | 186 graphData[revision] = traces; |
| 187 | 187 |
| 188 // Collect unique trace names. | 188 // Collect unique trace names. |
| 189 for (var traceName in traces) | 189 for (var traceName in traces) |
| 190 allTraces[traceName] = 1; | 190 allTraces[traceName] = 1; |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Sort trace names, putting traces with corresponding _ref lines first | |
| 194 // under the assumption that those are the most interesting ones. | |
| 195 // Returns 1 if name1 is larger, -1 if it's smaller, and 0 if they're equal. | |
| 196 // Use a closure so we have access to allTraces. | |
| 197 function trace_compare(name1, name2) { | |
|
ojan
2009/02/20 02:46:41
There's a lot of places where you do the same thin
| |
| 198 function compare(x, y) { | |
| 199 return ((x < y) ? -1 : (x > y) ? 1 : 0); | |
| 200 } | |
| 201 | |
| 202 // The main trace name associated with this _ref name, and whether this is | |
| 203 // in fact a _ref trace. | |
| 204 main1 = name1.substring(0, name1.length - 4); | |
| 205 main2 = name2.substring(0, name2.length - 4); | |
| 206 is_ref1 = name1.substr(-4) == "_ref" && main1 in allTraces; | |
| 207 is_ref2 = name2.substr(-4) == "_ref" && main2 in allTraces; | |
| 208 | |
| 209 // Whether this trace has a corresponding _ref. If so, it's its own main | |
| 210 // trace. | |
| 211 is_main1 = name1 + "_ref" in allTraces; | |
| 212 is_main2 = name2 + "_ref" in allTraces; | |
| 213 if (is_main1) | |
| 214 main1 = name1; | |
| 215 if (is_main2) | |
| 216 main2 = name2; | |
| 217 | |
| 218 // A main trace is smaller than its own _ref, compared alphabetically by | |
| 219 // main name to any other main or _ref traces, and smaller than anything | |
| 220 // else. | |
| 221 if (is_main1) { | |
| 222 if (is_ref2 && main1 == main2) | |
| 223 return -1; | |
| 224 if (is_main2 || is_ref2) | |
| 225 return compare(main1, main2); | |
| 226 return -1; | |
| 227 } | |
| 228 if (is_ref1) { | |
| 229 if (is_main2 && main1 == main2) | |
| 230 return 1; | |
| 231 if (is_main2 || is_ref2) | |
| 232 return compare(main1, main2); | |
| 233 return -1; | |
| 234 } | |
| 235 if (is_main2 || is_ref2) | |
| 236 return 1; | |
| 237 return compare(name1, name2); | |
| 238 } | |
| 239 | |
| 193 // Build and sort a list of all the trace names we've seen. | 240 // Build and sort a list of all the trace names we've seen. |
| 194 var traceNames = []; | 241 var traceNames = []; |
| 195 for (var traceName in allTraces) | 242 for (var traceName in allTraces) |
| 196 traceNames.push(traceName); | 243 traceNames.push(traceName); |
| 197 traceNames.sort(); | 244 traceNames.sort(trace_compare); |
| 198 | 245 |
| 199 // Build and sort a list of revision numbers. | 246 // Build and sort a list of revision numbers. |
| 200 var revisionNumbers = []; | 247 var revisionNumbers = []; |
| 201 for (var rev in graphData) | 248 for (var rev in graphData) |
| 202 revisionNumbers.push(rev); | 249 revisionNumbers.push(rev); |
| 203 revisionNumbers.sort(); | 250 revisionNumbers.sort(); |
| 204 | 251 |
| 205 // Build separate ordered lists of trace data. | 252 // Build separate ordered lists of trace data. |
| 206 var traceData = {}; | 253 var traceData = {}; |
| 207 for (var revIndex = 0; revIndex < revisionNumbers.length; ++revIndex) { | 254 for (var revIndex = 0; revIndex < revisionNumbers.length; ++revIndex) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 details.style.display = "none"; | 396 details.style.display = "none"; |
| 350 header_text.style.display = "none"; | 397 header_text.style.display = "none"; |
| 351 explain.style.display = "none"; | 398 explain.style.display = "none"; |
| 352 selection.style.display = "none"; | 399 selection.style.display = "none"; |
| 353 } else { | 400 } else { |
| 354 document.getElementById("header_lookout").style.display = "none"; | 401 document.getElementById("header_lookout").style.display = "none"; |
| 355 } | 402 } |
| 356 </script> | 403 </script> |
| 357 </body> | 404 </body> |
| 358 </html> | 405 </html> |
| OLD | NEW |