| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 server.performance.analysis.timing; | 5 library server.performance.analysis.timing; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 exit(1); | 30 exit(1); |
| 31 } | 31 } |
| 32 source = args[SOURCE_OPTION]; | 32 source = args[SOURCE_OPTION]; |
| 33 priorityFile = args[PRIORITY_FILE_OPTION]; | 33 priorityFile = args[PRIORITY_FILE_OPTION]; |
| 34 testName = args[TEST_NAME_OPTION] ?? DEFAULT_TEST; | 34 testName = args[TEST_NAME_OPTION] ?? DEFAULT_TEST; |
| 35 | 35 |
| 36 switch (testName) { | 36 switch (testName) { |
| 37 case 'analysis': | 37 case 'analysis': |
| 38 defineReflectiveTests(AnalysisTimingIntegrationTest); | 38 defineReflectiveTests(AnalysisTimingIntegrationTest); |
| 39 break; | 39 break; |
| 40 case 'highlighting': |
| 41 defineReflectiveTests(HighlightingTimingIntegrationTest); |
| 42 break; |
| 40 case 'navigation': | 43 case 'navigation': |
| 41 defineReflectiveTests(NavigationTimingIntegrationTest); | 44 defineReflectiveTests(NavigationTimingIntegrationTest); |
| 42 break; | 45 break; |
| 46 case 'outline': |
| 47 defineReflectiveTests(OutlineTimingIntegrationTest); |
| 48 break; |
| 43 default: | 49 default: |
| 44 print('unrecognized test name $testName'); | 50 print('unrecognized test name $testName'); |
| 45 exit(1); | 51 exit(1); |
| 46 } | 52 } |
| 47 } | 53 } |
| 48 | 54 |
| 49 const DEFAULT_TEST = 'analysis'; | 55 const DEFAULT_TEST = 'analysis'; |
| 50 const PRIORITY_FILE_OPTION = 'priority'; | 56 const PRIORITY_FILE_OPTION = 'priority'; |
| 51 const SOURCE_OPTION = 'source'; | 57 const SOURCE_OPTION = 'source'; |
| 52 const TEST_NAME_OPTION = 'test'; | 58 const TEST_NAME_OPTION = 'test'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 sendAnalysisSetPriorityFiles([priorityFile]); | 84 sendAnalysisSetPriorityFiles([priorityFile]); |
| 79 } | 85 } |
| 80 return analysisFinished.then((_) { | 86 return analysisFinished.then((_) { |
| 81 print('analysis completed in ${stopwatch.elapsed}'); | 87 print('analysis completed in ${stopwatch.elapsed}'); |
| 82 stopwatch.reset(); | 88 stopwatch.reset(); |
| 83 }); | 89 }); |
| 84 } | 90 } |
| 85 } | 91 } |
| 86 | 92 |
| 87 @reflectiveTest | 93 @reflectiveTest |
| 88 class NavigationTimingIntegrationTest extends AbstractTimingTest { | 94 class HighlightingTimingIntegrationTest extends PriorityFileTimer { |
| 89 Future test_detect_navigation_done() { | 95 @override |
| 90 expect(priorityFile, isNotNull); | 96 String get description => 'highlighting'; |
| 97 |
| 98 @override |
| 99 Stream get eventStream => onAnalysisHighlights; |
| 100 |
| 101 @override |
| 102 AnalysisService get service => AnalysisService.HIGHLIGHTS; |
| 103 } |
| 104 |
| 105 @reflectiveTest |
| 106 class NavigationTimingIntegrationTest extends PriorityFileTimer { |
| 107 @override |
| 108 String get description => 'navigation'; |
| 109 |
| 110 @override |
| 111 Stream get eventStream => onAnalysisNavigation; |
| 112 |
| 113 @override |
| 114 AnalysisService get service => AnalysisService.NAVIGATION; |
| 115 } |
| 116 |
| 117 @reflectiveTest |
| 118 class OutlineTimingIntegrationTest extends PriorityFileTimer { |
| 119 @override |
| 120 String get description => 'outline'; |
| 121 |
| 122 @override |
| 123 Stream get eventStream => onAnalysisOutline; |
| 124 |
| 125 @override |
| 126 AnalysisService get service => AnalysisService.OUTLINE; |
| 127 } |
| 128 |
| 129 abstract class PriorityFileTimer extends AbstractTimingTest { |
| 130 String get description; |
| 131 Stream get eventStream; |
| 132 AnalysisService get service; |
| 133 |
| 134 Future test_timing() { |
| 135 expect(priorityFile, isNotNull, |
| 136 reason: 'A priority file must be specified for $description testing.'); |
| 91 stopwatch.start(); | 137 stopwatch.start(); |
| 92 | 138 |
| 93 Duration elapsed; | 139 Duration elapsed; |
| 94 onAnalysisNavigation.listen((AnalysisNavigationParams params) { | 140 eventStream.listen((_) { |
| 95 elapsed = stopwatch.elapsed; | 141 elapsed = stopwatch.elapsed; |
| 96 }); | 142 }); |
| 97 | 143 |
| 98 setAnalysisRoot(); | 144 setAnalysisRoot(); |
| 99 sendAnalysisSetSubscriptions({ | 145 sendAnalysisSetSubscriptions({ |
| 100 AnalysisService.NAVIGATION: [priorityFile] | 146 service: [priorityFile] |
| 101 }); | 147 }); |
| 102 | 148 |
| 103 sendAnalysisSetPriorityFiles([priorityFile]); | 149 sendAnalysisSetPriorityFiles([priorityFile]); |
| 104 | 150 |
| 105 return analysisFinished.then((_) { | 151 return analysisFinished.then((_) { |
| 106 print('navigation completed in ${elapsed}'); | 152 print('$description completed in ${elapsed}'); |
| 107 stopwatch.reset(); | 153 stopwatch.reset(); |
| 108 }); | 154 }); |
| 109 } | 155 } |
| 110 } | 156 } |
| OLD | NEW |