| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 get.handler; | 5 library get.handler; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| 11 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
| 12 import 'package:analysis_server/src/domain_completion.dart'; | 12 import 'package:analysis_server/src/domain_completion.dart'; |
| 13 import 'package:analysis_server/src/socket_server.dart'; | 13 import 'package:analysis_server/src/socket_server.dart'; |
| 14 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
| 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/java_engine.dart'; | 17 import 'package:analyzer/src/generated/java_engine.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
| 18 | 19 |
| 19 import 'analysis_server.dart'; | 20 import 'analysis_server.dart'; |
| 20 | 21 |
| 21 /** | 22 /** |
| 22 * Instances of the class [GetHandler] handle GET requests. | 23 * Instances of the class [GetHandler] handle GET requests. |
| 23 */ | 24 */ |
| 24 class GetHandler { | 25 class GetHandler { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 561 } |
| 561 if (maxCount is String) { | 562 if (maxCount is String) { |
| 562 int count = int.parse(maxCount, onError: (_) => 0); | 563 int count = int.parse(maxCount, onError: (_) => 0); |
| 563 handler.performanceListMaxLength = count; | 564 handler.performanceListMaxLength = count; |
| 564 } | 565 } |
| 565 CompletionPerformance performance = handler.performance; | 566 CompletionPerformance performance = handler.performance; |
| 566 if (performance == null) { | 567 if (performance == null) { |
| 567 response.write('<p>No performance stats yet</p>'); | 568 response.write('<p>No performance stats yet</p>'); |
| 568 return; | 569 return; |
| 569 } | 570 } |
| 571 response.write('<h2>Last Completion Performance</h2>'); |
| 570 response.write('<table>'); | 572 response.write('<table>'); |
| 571 _writeRow(response, ['Elapsed', '', 'Operation'], header: true); | 573 _writeRow(response, ['Elapsed', '', 'Operation'], header: true); |
| 572 performance.operations.forEach((OperationPerformance op) { | 574 performance.operations.forEach((OperationPerformance op) { |
| 573 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???'; | 575 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???'; |
| 574 _writeRow(response, [elapsed, ' ', op.name]); | 576 _writeRow(response, [elapsed, ' ', op.name]); |
| 575 }); | 577 }); |
| 576 if (handler.priorityChangedPerformance == null) { | 578 if (handler.priorityChangedPerformance == null) { |
| 577 response.write('<p>No priorityChanged caching</p>'); | 579 response.write('<p>No priorityChanged caching</p>'); |
| 578 } else { | 580 } else { |
| 579 int len = handler.priorityChangedPerformance.operations.length; | 581 int len = handler.priorityChangedPerformance.operations.length; |
| 580 if (len > 0) { | 582 if (len > 0) { |
| 581 var op = handler.priorityChangedPerformance.operations[len - 1]; | 583 var op = handler.priorityChangedPerformance.operations[len - 1]; |
| 582 if (op != null) { | 584 if (op != null) { |
| 583 _writeRow(response, [' ', ' ', ' ']); | 585 _writeRow(response, [' ', ' ', ' ']); |
| 584 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???'; | 586 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???'; |
| 585 _writeRow(response, [elapsed, ' ', op.name]); | 587 _writeRow(response, [elapsed, ' ', op.name]); |
| 586 } | 588 } |
| 587 } | 589 } |
| 588 } | 590 } |
| 589 response.write('</table>'); | 591 response.write('</table>'); |
| 590 if (handler.performanceList.length > 0) { | 592 if (handler.performanceList.length > 0) { |
| 593 response.write('<h2>Last Completion Summary</h2>'); |
| 591 response.write('<table>'); | 594 response.write('<table>'); |
| 592 _writeRow( | 595 _writeRow( |
| 593 response, | 596 response, |
| 594 ['Milliseconds', '', '# Notifications', '', '# Suggestions', '', 'Snip
pet'], | 597 [ |
| 598 'Start Time', |
| 599 '', |
| 600 'First (ms)', |
| 601 '', |
| 602 'Complete (ms)', |
| 603 '', |
| 604 '# Notifications', |
| 605 '', |
| 606 '# Suggestions', |
| 607 '', |
| 608 'Snippet'], |
| 595 header: true); | 609 header: true); |
| 596 handler.performanceList.forEach((CompletionPerformance performance) { | 610 handler.performanceList.forEach((CompletionPerformance performance) { |
| 597 _writeRow( | 611 _writeRow( |
| 598 response, | 612 response, |
| 599 [ | 613 [ |
| 614 performance.start, |
| 615 ' ', |
| 616 performance.firstNotificationInMilliseconds, |
| 617 ' ', |
| 600 performance.elapsedInMilliseconds, | 618 performance.elapsedInMilliseconds, |
| 601 ' ', | 619 ' ', |
| 602 performance.notificationCount, | 620 performance.notificationCount, |
| 603 ' ', | 621 ' ', |
| 604 performance.suggestionCount, | 622 performance.suggestionCount, |
| 605 ' ', | 623 ' ', |
| 606 performance.snippet]); | 624 performance.snippet]); |
| 607 }); | 625 }); |
| 608 response.write('</table>'); | 626 response.write('</table>'); |
| 609 } | 627 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 636 if (header) { | 654 if (header) { |
| 637 response.write('</th>'); | 655 response.write('</th>'); |
| 638 } else { | 656 } else { |
| 639 response.write('</td>'); | 657 response.write('</td>'); |
| 640 } | 658 } |
| 641 } | 659 } |
| 642 | 660 |
| 643 response.write('</tr>'); | 661 response.write('</tr>'); |
| 644 } | 662 } |
| 645 } | 663 } |
| OLD | NEW |