| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library cpu_profile_table_element; | 5 library cpu_profile_table_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
| 10 import 'package:observatory/src/elements/containers/virtual_collection.dart'; | 10 import 'package:observatory/src/elements/containers/virtual_collection.dart'; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } else { | 222 } else { |
| 223 e.classes = ['function-item']; | 223 e.classes = ['function-item']; |
| 224 } | 224 } |
| 225 e.children[0].text = Utils.formatPercentNormalized(_getExclusiveT(item)); | 225 e.children[0].text = Utils.formatPercentNormalized(_getExclusiveT(item)); |
| 226 e.children[1].text = Utils.formatPercentNormalized(_getInclusiveT(item)); | 226 e.children[1].text = Utils.formatPercentNormalized(_getInclusiveT(item)); |
| 227 e.children[2] = | 227 e.children[2] = |
| 228 new FunctionRefElement(_isolate, item.function, queue: _r.queue) | 228 new FunctionRefElement(_isolate, item.function, queue: _r.queue) |
| 229 ..classes = ['name']; | 229 ..classes = ['name']; |
| 230 } | 230 } |
| 231 | 231 |
| 232 Element _createFunctionHeader() => new DivElement() | 232 List<HtmlElement> _createFunctionHeader() => [ |
| 233 ..classes = ['function-item'] | 233 new DivElement() |
| 234 ..children = [ | 234 ..classes = ['function-item'] |
| 235 _createHeaderButton(const ['exclusive'], 'Execution(%)', _Table.functions, | 235 ..children = [ |
| 236 _SortingField.exclusive, _SortingDirection.descending), | 236 _createHeaderButton( |
| 237 _createHeaderButton(const ['inclusive'], 'Stack(%)', _Table.functions, | 237 const ['exclusive'], |
| 238 _SortingField.inclusive, _SortingDirection.descending), | 238 'Execution(%)', |
| 239 _createHeaderButton(const ['name'], 'Method', _Table.functions, | 239 _Table.functions, |
| 240 _SortingField.method, _SortingDirection.ascending), | 240 _SortingField.exclusive, |
| 241 ]; | 241 _SortingDirection.descending), |
| 242 _createHeaderButton( |
| 243 const ['inclusive'], |
| 244 'Stack(%)', |
| 245 _Table.functions, |
| 246 _SortingField.inclusive, |
| 247 _SortingDirection.descending), |
| 248 _createHeaderButton(const ['name'], 'Method', _Table.functions, |
| 249 _SortingField.method, _SortingDirection.ascending), |
| 250 ] |
| 251 ]; |
| 242 | 252 |
| 243 void _setSorting( | 253 void _setSorting( |
| 244 _Table table, _SortingField field, _SortingDirection defaultDirection) { | 254 _Table table, _SortingField field, _SortingDirection defaultDirection) { |
| 245 if (_sortingField[table] == field) { | 255 if (_sortingField[table] == field) { |
| 246 switch (_sortingDirection[table]) { | 256 switch (_sortingDirection[table]) { |
| 247 case _SortingDirection.descending: | 257 case _SortingDirection.descending: |
| 248 _sortingDirection[table] = _SortingDirection.ascending; | 258 _sortingDirection[table] = _SortingDirection.ascending; |
| 249 break; | 259 break; |
| 250 case _SortingDirection.ascending: | 260 case _SortingDirection.ascending: |
| 251 _sortingDirection[table] = _SortingDirection.descending; | 261 _sortingDirection[table] = _SortingDirection.descending; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 277 return element; | 287 return element; |
| 278 } | 288 } |
| 279 | 289 |
| 280 void _updateCallee(Element e, item, int index) { | 290 void _updateCallee(Element e, item, int index) { |
| 281 e.children[0].text = Utils.formatPercentNormalized(_getCalleeT(item)); | 291 e.children[0].text = Utils.formatPercentNormalized(_getCalleeT(item)); |
| 282 e.children[1] = | 292 e.children[1] = |
| 283 new FunctionRefElement(_isolate, item.function, queue: _r.queue) | 293 new FunctionRefElement(_isolate, item.function, queue: _r.queue) |
| 284 ..classes = ['name']; | 294 ..classes = ['name']; |
| 285 } | 295 } |
| 286 | 296 |
| 287 Element _createCalleeHeader() => new DivElement() | 297 List<HtmlElement> _createCalleeHeader() => [ |
| 288 ..classes = ['function-item'] | 298 new DivElement() |
| 289 ..children = [ | 299 ..classes = ['function-item'] |
| 290 _createHeaderButton(const ['inclusive'], 'Callees(%)', _Table.callee, | 300 ..children = [ |
| 291 _SortingField.callee, _SortingDirection.descending), | 301 _createHeaderButton( |
| 292 _createHeaderButton(const ['name'], 'Method', _Table.callee, | 302 const ['inclusive'], |
| 293 _SortingField.method, _SortingDirection.ascending), | 303 'Callees(%)', |
| 294 ]; | 304 _Table.callee, |
| 305 _SortingField.callee, |
| 306 _SortingDirection.descending), |
| 307 _createHeaderButton(const ['name'], 'Method', _Table.callee, |
| 308 _SortingField.method, _SortingDirection.ascending), |
| 309 ] |
| 310 ]; |
| 295 | 311 |
| 296 Element _createCaller() { | 312 Element _createCaller() { |
| 297 final element = new DivElement() | 313 final element = new DivElement() |
| 298 ..classes = ['function-item'] | 314 ..classes = ['function-item'] |
| 299 ..children = [ | 315 ..children = [ |
| 300 new SpanElement() | 316 new SpanElement() |
| 301 ..classes = ['inclusive'] | 317 ..classes = ['inclusive'] |
| 302 ..text = '0%', | 318 ..text = '0%', |
| 303 new SpanElement()..classes = ['name'] | 319 new SpanElement()..classes = ['name'] |
| 304 ]; | 320 ]; |
| 305 element.onClick.listen((e) { | 321 element.onClick.listen((e) { |
| 306 if (e.target is AnchorElement) { | 322 if (e.target is AnchorElement) { |
| 307 return; | 323 return; |
| 308 } | 324 } |
| 309 _selected = _callers.getItemFromElement(element); | 325 _selected = _callers.getItemFromElement(element); |
| 310 _r.dirty(); | 326 _r.dirty(); |
| 311 }); | 327 }); |
| 312 return element; | 328 return element; |
| 313 } | 329 } |
| 314 | 330 |
| 315 void _updateCaller(Element e, item, int index) { | 331 void _updateCaller(Element e, item, int index) { |
| 316 e.children[0].text = Utils.formatPercentNormalized(_getCallerT(item)); | 332 e.children[0].text = Utils.formatPercentNormalized(_getCallerT(item)); |
| 317 e.children[1] = | 333 e.children[1] = |
| 318 new FunctionRefElement(_isolate, item.function, queue: _r.queue) | 334 new FunctionRefElement(_isolate, item.function, queue: _r.queue) |
| 319 ..classes = ['name']; | 335 ..classes = ['name']; |
| 320 } | 336 } |
| 321 | 337 |
| 322 Element _createCallerHeader() => new DivElement() | 338 List<HtmlElement> _createCallerHeader() => [ |
| 323 ..classes = ['function-item'] | 339 new DivElement() |
| 324 ..children = [ | 340 ..classes = ['function-item'] |
| 325 _createHeaderButton(const ['inclusive'], 'Callers(%)', _Table.caller, | 341 ..children = [ |
| 326 _SortingField.caller, _SortingDirection.descending), | 342 _createHeaderButton( |
| 327 _createHeaderButton(const ['name'], 'Method', _Table.caller, | 343 const ['inclusive'], |
| 328 _SortingField.method, _SortingDirection.ascending), | 344 'Callers(%)', |
| 329 ]; | 345 _Table.caller, |
| 346 _SortingField.caller, |
| 347 _SortingDirection.descending), |
| 348 _createHeaderButton(const ['name'], 'Method', _Table.caller, |
| 349 _SortingField.method, _SortingDirection.ascending), |
| 350 ] |
| 351 ]; |
| 330 | 352 |
| 331 ButtonElement _createHeaderButton(List<String> classes, String text, | 353 ButtonElement _createHeaderButton(List<String> classes, String text, |
| 332 _Table table, _SortingField field, _SortingDirection direction) => | 354 _Table table, _SortingField field, _SortingDirection direction) => |
| 333 new ButtonElement() | 355 new ButtonElement() |
| 334 ..classes = classes | 356 ..classes = classes |
| 335 ..text = _sortingField[table] != field | 357 ..text = _sortingField[table] != field |
| 336 ? text | 358 ? text |
| 337 : _sortingDirection[table] == _SortingDirection.ascending | 359 : _sortingDirection[table] == _SortingDirection.ascending |
| 338 ? '$text▼' | 360 ? '$text▼' |
| 339 : '$text▲' | 361 : '$text▲' |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 455 |
| 434 static double _getExclusiveT(M.ProfileFunction f) => | 456 static double _getExclusiveT(M.ProfileFunction f) => |
| 435 f.normalizedExclusiveTicks; | 457 f.normalizedExclusiveTicks; |
| 436 static double _getInclusiveT(M.ProfileFunction f) => | 458 static double _getInclusiveT(M.ProfileFunction f) => |
| 437 f.normalizedInclusiveTicks; | 459 f.normalizedInclusiveTicks; |
| 438 double _getCalleeT(M.ProfileFunction f) => | 460 double _getCalleeT(M.ProfileFunction f) => |
| 439 _selected.callees[f] / _selected.callees.values.reduce((a, b) => a + b); | 461 _selected.callees[f] / _selected.callees.values.reduce((a, b) => a + b); |
| 440 double _getCallerT(M.ProfileFunction f) => | 462 double _getCallerT(M.ProfileFunction f) => |
| 441 _selected.callers[f] / _selected.callers.values.reduce((a, b) => a + b); | 463 _selected.callers[f] / _selected.callers.values.reduce((a, b) => a + b); |
| 442 } | 464 } |
| OLD | NEW |