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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 queue : _r.queue)], | 208 queue : _r.queue)], |
209 new DivElement()..classes = ['profile-trees-callee'] | 209 new DivElement()..classes = ['profile-trees-callee'] |
210 ..children = [_callees] | 210 ..children = [_callees] |
211 ] | 211 ] |
212 ] | 212 ] |
213 ]; | 213 ]; |
214 } | 214 } |
215 | 215 |
216 Element _createFunction() { | 216 Element _createFunction() { |
217 final element = new DivElement() | 217 final element = new DivElement() |
218 ..classes = const ['function-item'] | 218 ..classes = ['function-item'] |
219 ..children = [ | 219 ..children = [ |
220 new SpanElement()..classes = const ['exclusive'] | 220 new SpanElement()..classes = ['exclusive'] |
221 ..text = '0%', | 221 ..text = '0%', |
222 new SpanElement()..classes = const ['inclusive'] | 222 new SpanElement()..classes = ['inclusive'] |
223 ..text = '0%', | 223 ..text = '0%', |
224 new SpanElement()..classes = const ['name'] | 224 new SpanElement()..classes = ['name'] |
225 ]; | 225 ]; |
226 element.onClick.listen((e) { | 226 element.onClick.listen((e) { |
227 if (e.target is AnchorElement) { | 227 if (e.target is AnchorElement) { |
228 return; | 228 return; |
229 } | 229 } |
230 _selected = _functions.getItemFromElement(element); | 230 _selected = _functions.getItemFromElement(element); |
231 _r.dirty(); | 231 _r.dirty(); |
232 }); | 232 }); |
233 return element; | 233 return element; |
234 } | 234 } |
235 | 235 |
236 void _updateFunction(Element e, M.ProfileFunction item, int index) { | 236 void _updateFunction(Element e, M.ProfileFunction item, int index) { |
237 if (item == _selected) { | 237 if (item == _selected) { |
238 e.classes = const ['function-item', 'selected']; | 238 e.classes = ['function-item', 'selected']; |
239 } else { | 239 } else { |
240 e.classes = const ['function-item']; | 240 e.classes = ['function-item']; |
241 } | 241 } |
242 e.children[0].text = Utils.formatPercentNormalized(_getExclusiveT(item)); | 242 e.children[0].text = Utils.formatPercentNormalized(_getExclusiveT(item)); |
243 e.children[1].text = Utils.formatPercentNormalized(_getInclusiveT(item)); | 243 e.children[1].text = Utils.formatPercentNormalized(_getInclusiveT(item)); |
244 e.children[2] = new FunctionRefElement(_isolate, item.function, | 244 e.children[2] = new FunctionRefElement(_isolate, item.function, |
245 queue: _r.queue)..classes = const ['name']; | 245 queue: _r.queue)..classes = ['name']; |
246 } | 246 } |
247 | 247 |
248 Element _createFunctionHeader() => | 248 Element _createFunctionHeader() => |
249 new DivElement() | 249 new DivElement() |
250 ..classes = const ['function-item'] | 250 ..classes = ['function-item'] |
251 ..children = [ | 251 ..children = [ |
252 _createHeaderButton(const ['exclusive'], 'Execution(%)', | 252 _createHeaderButton(const ['exclusive'], 'Execution(%)', |
253 _Table.functions, | 253 _Table.functions, |
254 _SortingField.exclusive, | 254 _SortingField.exclusive, |
255 _SortingDirection.descending), | 255 _SortingDirection.descending), |
256 _createHeaderButton(const ['inclusive'], 'Stack(%)', | 256 _createHeaderButton(const ['inclusive'], 'Stack(%)', |
257 _Table.functions, | 257 _Table.functions, |
258 _SortingField.inclusive, | 258 _SortingField.inclusive, |
259 _SortingDirection.descending), | 259 _SortingDirection.descending), |
260 _createHeaderButton(const ['name'], 'Method', | 260 _createHeaderButton(const ['name'], 'Method', |
(...skipping 16 matching lines...) Expand all Loading... |
277 } | 277 } |
278 } else { | 278 } else { |
279 _sortingDirection[table] = defaultDirection; | 279 _sortingDirection[table] = defaultDirection; |
280 _sortingField[table] = field; | 280 _sortingField[table] = field; |
281 } | 281 } |
282 _r.dirty(); | 282 _r.dirty(); |
283 } | 283 } |
284 | 284 |
285 Element _createCallee() { | 285 Element _createCallee() { |
286 final element = new DivElement() | 286 final element = new DivElement() |
287 ..classes = const ['function-item'] | 287 ..classes = ['function-item'] |
288 ..children = [ | 288 ..children = [ |
289 new SpanElement()..classes = const ['inclusive'] | 289 new SpanElement()..classes = ['inclusive'] |
290 ..text = '0%', | 290 ..text = '0%', |
291 new SpanElement()..classes = const ['name'] | 291 new SpanElement()..classes = ['name'] |
292 ]; | 292 ]; |
293 element.onClick.listen((e) { | 293 element.onClick.listen((e) { |
294 if (e.target is AnchorElement) { | 294 if (e.target is AnchorElement) { |
295 return; | 295 return; |
296 } | 296 } |
297 _selected = _callees.getItemFromElement(element); | 297 _selected = _callees.getItemFromElement(element); |
298 _r.dirty(); | 298 _r.dirty(); |
299 }); | 299 }); |
300 return element; | 300 return element; |
301 } | 301 } |
302 | 302 |
303 void _updateCallee(Element e, item, int index) { | 303 void _updateCallee(Element e, item, int index) { |
304 e.children[0].text = Utils.formatPercentNormalized(_getCalleeT(item)); | 304 e.children[0].text = Utils.formatPercentNormalized(_getCalleeT(item)); |
305 e.children[1] = new FunctionRefElement(_isolate, item.function, | 305 e.children[1] = new FunctionRefElement(_isolate, item.function, |
306 queue: _r.queue)..classes = const ['name']; | 306 queue: _r.queue)..classes = ['name']; |
307 } | 307 } |
308 | 308 |
309 Element _createCalleeHeader() => | 309 Element _createCalleeHeader() => |
310 new DivElement() | 310 new DivElement() |
311 ..classes = const ['function-item'] | 311 ..classes = ['function-item'] |
312 ..children = [ | 312 ..children = [ |
313 _createHeaderButton(const ['inclusive'], 'Callees(%)', | 313 _createHeaderButton(const ['inclusive'], 'Callees(%)', |
314 _Table.callee, | 314 _Table.callee, |
315 _SortingField.callee, | 315 _SortingField.callee, |
316 _SortingDirection.descending), | 316 _SortingDirection.descending), |
317 _createHeaderButton(const ['name'], 'Method', | 317 _createHeaderButton(const ['name'], 'Method', |
318 _Table.callee, | 318 _Table.callee, |
319 _SortingField.method, | 319 _SortingField.method, |
320 _SortingDirection.descending), | 320 _SortingDirection.descending), |
321 ]; | 321 ]; |
322 | 322 |
323 Element _createCaller() { | 323 Element _createCaller() { |
324 final element = new DivElement() | 324 final element = new DivElement() |
325 ..classes = const ['function-item'] | 325 ..classes = ['function-item'] |
326 ..children = [ | 326 ..children = [ |
327 new SpanElement()..classes = const ['inclusive'] | 327 new SpanElement()..classes = ['inclusive'] |
328 ..text = '0%', | 328 ..text = '0%', |
329 new SpanElement()..classes = const ['name'] | 329 new SpanElement()..classes = ['name'] |
330 ]; | 330 ]; |
331 element.onClick.listen((e) { | 331 element.onClick.listen((e) { |
332 if (e.target is AnchorElement) { | 332 if (e.target is AnchorElement) { |
333 return; | 333 return; |
334 } | 334 } |
335 _selected = _callers.getItemFromElement(element); | 335 _selected = _callers.getItemFromElement(element); |
336 _r.dirty(); | 336 _r.dirty(); |
337 }); | 337 }); |
338 return element; | 338 return element; |
339 } | 339 } |
340 | 340 |
341 void _updateCaller(Element e, item, int index) { | 341 void _updateCaller(Element e, item, int index) { |
342 e.children[0].text = Utils.formatPercentNormalized(_getCallerT(item)); | 342 e.children[0].text = Utils.formatPercentNormalized(_getCallerT(item)); |
343 e.children[1] = new FunctionRefElement(_isolate, item.function, | 343 e.children[1] = new FunctionRefElement(_isolate, item.function, |
344 queue: _r.queue)..classes = const ['name']; | 344 queue: _r.queue)..classes = ['name']; |
345 } | 345 } |
346 | 346 |
347 Element _createCallerHeader() => | 347 Element _createCallerHeader() => |
348 new DivElement() | 348 new DivElement() |
349 ..classes = const ['function-item'] | 349 ..classes = ['function-item'] |
350 ..children = [ | 350 ..children = [ |
351 _createHeaderButton(const ['inclusive'], 'Callers(%)', | 351 _createHeaderButton(const ['inclusive'], 'Callers(%)', |
352 _Table.caller, | 352 _Table.caller, |
353 _SortingField.caller, | 353 _SortingField.caller, |
354 _SortingDirection.descending), | 354 _SortingDirection.descending), |
355 _createHeaderButton(const ['name'], 'Method', | 355 _createHeaderButton(const ['name'], 'Method', |
356 _Table.caller, | 356 _Table.caller, |
357 _SortingField.method, | 357 _SortingField.method, |
358 _SortingDirection.descending), | 358 _SortingDirection.descending), |
359 ]; | 359 ]; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 static double _getExclusiveT(M.ProfileFunction f) => | 452 static double _getExclusiveT(M.ProfileFunction f) => |
453 f.normalizedExclusiveTicks; | 453 f.normalizedExclusiveTicks; |
454 static double _getInclusiveT(M.ProfileFunction f) => | 454 static double _getInclusiveT(M.ProfileFunction f) => |
455 f.normalizedInclusiveTicks; | 455 f.normalizedInclusiveTicks; |
456 double _getCalleeT(M.ProfileFunction f) => | 456 double _getCalleeT(M.ProfileFunction f) => |
457 _selected.callees[f] / _selected.callees.values.reduce((a, b) => a + b); | 457 _selected.callees[f] / _selected.callees.values.reduce((a, b) => a + b); |
458 double _getCallerT(M.ProfileFunction f) => | 458 double _getCallerT(M.ProfileFunction f) => |
459 _selected.callers[f] / _selected.callers.values.reduce((a, b) => a + b); | 459 _selected.callers[f] / _selected.callers.values.reduce((a, b) => a + b); |
460 } | 460 } |
OLD | NEW |