| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library server.performance.local; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | |
| 10 | |
| 11 import 'benchmark_scenario.dart'; | |
| 12 import 'memory_tests.dart'; | |
| 13 | |
| 14 main(List<String> args) async { | |
| 15 int length = args.length; | |
| 16 if (length < 1) { | |
| 17 print( | |
| 18 'Usage: dart benchmark_local.dart path_to_sdk_checkout [path_to_flutter_
checkout]'); | |
| 19 return; | |
| 20 } else if (length == 1) { | |
| 21 paths = new PathHolder(sdkPath: args[0]); | |
| 22 } else { | |
| 23 paths = new PathHolder(sdkPath: args[0], flutterPath: args[1]); | |
| 24 } | |
| 25 String now = new DateTime.now().toUtc().toIso8601String(); | |
| 26 print('Benchmark started: $now'); | |
| 27 print(''); | |
| 28 print(''); | |
| 29 await run_local_initialAnalysis_1(); | |
| 30 await run_local_initialAnalysis_2(); | |
| 31 await run_local_initialAnalysis_3(); | |
| 32 await run_local_change_1(); | |
| 33 await run_local_change_2(); | |
| 34 await run_local_completion_1(); | |
| 35 await run_local_completion_2(); | |
| 36 await run_local_completion_3(); | |
| 37 await run_local_completion_4(); | |
| 38 await run_local_refactoring_1(); | |
| 39 | |
| 40 await run_memory_initialAnalysis_1(); | |
| 41 await run_memory_initialAnalysis_2(); | |
| 42 } | |
| 43 | |
| 44 PathHolder paths; | |
| 45 | |
| 46 Future run_local_change_1() async { | |
| 47 String id = 'local-change-1'; | |
| 48 String description = r''' | |
| 49 1. Open 'analyzer'. | |
| 50 2. Change a method body in src/task/dart.dart. | |
| 51 3. Measure the time to finish analysis. | |
| 52 4. Rollback changes to the file and wait for analysis. | |
| 53 5. Go to (2). | |
| 54 '''; | |
| 55 List<int> times = await new BenchmarkScenario().waitAnalyze_change_analyze( | |
| 56 roots: [paths.analyzer], | |
| 57 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 58 fileChange: new FileChange( | |
| 59 afterStr: 'if (hasDirectiveChange) {', insertStr: 'print(12345);'), | |
| 60 numOfRepeats: 10); | |
| 61 printBenchmarkResults(id, description, times); | |
| 62 } | |
| 63 | |
| 64 Future run_local_change_2() async { | |
| 65 String id = 'local-change-2'; | |
| 66 String description = r''' | |
| 67 1. Open 'analyzer'. | |
| 68 2. Change the name of a public method in src/task/dart.dart. | |
| 69 3. Measure the time to finish analysis. | |
| 70 4. Rollback changes to the file and wait for analysis. | |
| 71 5. Go to (2). | |
| 72 '''; | |
| 73 List<int> times = await new BenchmarkScenario().waitAnalyze_change_analyze( | |
| 74 roots: [paths.analyzer], | |
| 75 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 76 fileChange: new FileChange( | |
| 77 afterStr: 'resolveDirective(An', | |
| 78 afterStrBack: 3, | |
| 79 insertStr: 'NewName'), | |
| 80 numOfRepeats: 5); | |
| 81 printBenchmarkResults(id, description, times); | |
| 82 } | |
| 83 | |
| 84 Future run_local_completion_1() async { | |
| 85 String id = 'local-completion-1'; | |
| 86 String description = r''' | |
| 87 1. Open 'analyzer'. | |
| 88 2. Change a method body in src/task/dart.dart. | |
| 89 3. Request code completion in this method and measure time to get results. | |
| 90 4. Rollback changes to the file and wait for analysis. | |
| 91 5. Go to (2). | |
| 92 '''; | |
| 93 List<int> times = await new BenchmarkScenario() | |
| 94 .waitAnalyze_change_getCompletion( | |
| 95 roots: [paths.analyzer], | |
| 96 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 97 fileChange: new FileChange( | |
| 98 afterStr: 'if (hasDirectiveChange) {', | |
| 99 insertStr: 'print(12345);'), | |
| 100 completeAfterStr: 'print(12345);', | |
| 101 numOfRepeats: 10); | |
| 102 printBenchmarkResults(id, description, times); | |
| 103 } | |
| 104 | |
| 105 Future run_local_completion_2() async { | |
| 106 String id = 'local-completion-2'; | |
| 107 String description = r''' | |
| 108 1. Open 'analyzer'. | |
| 109 2. Change the name of a public method in src/task/dart.dart. | |
| 110 3. Request code completion in this method and measure time to get results. | |
| 111 4. Rollback changes to the file and wait for analysis. | |
| 112 5. Go to (2). | |
| 113 '''; | |
| 114 List<int> times = await new BenchmarkScenario() | |
| 115 .waitAnalyze_change_getCompletion( | |
| 116 roots: [paths.analyzer], | |
| 117 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 118 fileChange: new FileChange( | |
| 119 afterStr: 'DeltaResult validate(In', | |
| 120 afterStrBack: 3, | |
| 121 insertStr: 'NewName'), | |
| 122 completeAfterStr: 'if (hasDirectiveChange) {', | |
| 123 numOfRepeats: 5); | |
| 124 printBenchmarkResults(id, description, times); | |
| 125 } | |
| 126 | |
| 127 Future run_local_completion_3() async { | |
| 128 String id = 'local-completion-3'; | |
| 129 String description = r''' | |
| 130 1. Open 'analysis_server' and 'analyzer'. | |
| 131 2. Change a method body in src/task/dart.dart. | |
| 132 3. Request code completion in this method and measure time to get results. | |
| 133 4. Rollback changes to the file and wait for analysis. | |
| 134 5. Go to (2). | |
| 135 '''; | |
| 136 List<int> times = await new BenchmarkScenario() | |
| 137 .waitAnalyze_change_getCompletion( | |
| 138 roots: [paths.analysisServer, paths.analyzer], | |
| 139 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 140 fileChange: new FileChange( | |
| 141 afterStr: 'if (hasDirectiveChange) {', | |
| 142 insertStr: 'print(12345);'), | |
| 143 completeAfterStr: 'print(12345);', | |
| 144 numOfRepeats: 10); | |
| 145 printBenchmarkResults(id, description, times); | |
| 146 } | |
| 147 | |
| 148 Future run_local_completion_4() async { | |
| 149 String id = 'local-completion-4'; | |
| 150 String description = r''' | |
| 151 1. Open 'analysis_server' and 'analyzer'. | |
| 152 2. Change the name of a public method in src/task/dart.dart. | |
| 153 3. Request code completion in this method and measure time to get results. | |
| 154 4. Rollback changes to the file and wait for analysis. | |
| 155 5. Go to (2). | |
| 156 '''; | |
| 157 List<int> times = await new BenchmarkScenario() | |
| 158 .waitAnalyze_change_getCompletion( | |
| 159 roots: [paths.analysisServer, paths.analyzer], | |
| 160 file: '${paths.analyzer}/lib/src/task/dart.dart', | |
| 161 fileChange: new FileChange( | |
| 162 afterStr: 'DeltaResult validate(In', | |
| 163 afterStrBack: 3, | |
| 164 insertStr: 'NewName'), | |
| 165 completeAfterStr: 'if (hasDirectiveChange) {', | |
| 166 numOfRepeats: 5); | |
| 167 printBenchmarkResults(id, description, times); | |
| 168 } | |
| 169 | |
| 170 Future run_local_initialAnalysis_1() async { | |
| 171 String id = 'local-initialAnalysis-1'; | |
| 172 String description = r''' | |
| 173 1. Start server, set 'analyzer' analysis root. | |
| 174 2. Measure the time to finish initial analysis. | |
| 175 3. Shutdown the server. | |
| 176 4. Go to (1). | |
| 177 '''; | |
| 178 List<int> times = await BenchmarkScenario.start_waitInitialAnalysis_shutdown( | |
| 179 roots: [paths.analyzer], numOfRepeats: 3); | |
| 180 printBenchmarkResults(id, description, times); | |
| 181 } | |
| 182 | |
| 183 Future run_local_initialAnalysis_2() async { | |
| 184 String id = 'local-initialAnalysis-2'; | |
| 185 String description = r''' | |
| 186 1. Start server, set 'analyzer' and 'analysis_server' analysis roots. | |
| 187 2. Measure the time to finish initial analysis. | |
| 188 3. Shutdown the server. | |
| 189 4. Go to (1). | |
| 190 '''; | |
| 191 List<int> times = await BenchmarkScenario.start_waitInitialAnalysis_shutdown( | |
| 192 roots: [paths.analyzer, paths.analysisServer], numOfRepeats: 3); | |
| 193 printBenchmarkResults(id, description, times); | |
| 194 } | |
| 195 | |
| 196 Future run_local_initialAnalysis_3() async { | |
| 197 String id = 'local-initialAnalysis-3'; | |
| 198 String description = r''' | |
| 199 1. Start server, set 'hello_world' and 'stocks' analysis roots. | |
| 200 2. Measure the time to finish initial analysis. | |
| 201 3. Shutdown the server. | |
| 202 4. Go to (1). | |
| 203 '''; | |
| 204 List<int> times = await BenchmarkScenario.start_waitInitialAnalysis_shutdown( | |
| 205 roots: [paths.flutterHelloWorld, paths.flutterStocks], numOfRepeats: 3); | |
| 206 printBenchmarkResults(id, description, times); | |
| 207 } | |
| 208 | |
| 209 Future run_local_refactoring_1() async { | |
| 210 String id = 'local-refactoring-1'; | |
| 211 String description = r''' | |
| 212 1. Open 'analyzer'. | |
| 213 2. Change the name of a public method in src/context/cache.dart. | |
| 214 3. Request rename refactoring for `getSourcesWithFullName` and measure time to g
et results. | |
| 215 4. Rollback changes to the file and wait for analysis. | |
| 216 5. Go to (2). | |
| 217 '''; | |
| 218 List<int> times = await new BenchmarkScenario() | |
| 219 .waitAnalyze_change_getRefactoring( | |
| 220 roots: [paths.analyzer], | |
| 221 file: '${paths.analyzer}/lib/src/context/cache.dart', | |
| 222 fileChange: new FileChange( | |
| 223 afterStr: 'getState(An', afterStrBack: 3, insertStr: 'NewName'), | |
| 224 refactoringAtStr: 'getSourcesWithFullName(String path)', | |
| 225 refactoringKind: RefactoringKind.RENAME, | |
| 226 refactoringOptions: new RenameOptions('getSourcesWithFullName2'), | |
| 227 numOfRepeats: 5); | |
| 228 printBenchmarkResults(id, description, times); | |
| 229 } | |
| 230 | |
| 231 Future run_memory_initialAnalysis_1() async { | |
| 232 String id = 'memory-initialAnalysis-1'; | |
| 233 String description = r''' | |
| 234 1. Start server, set 'analyzer' as the analysis root. | |
| 235 2. Measure the memory usage after finishing initial analysis. | |
| 236 3. Shutdown the server. | |
| 237 4. Go to (1). | |
| 238 '''; | |
| 239 List<int> sizes = await AnalysisServerMemoryUsageTest | |
| 240 .start_waitInitialAnalysis_shutdown( | |
| 241 roots: <String>[paths.analyzer], numOfRepeats: 3); | |
| 242 printMemoryResults(id, description, sizes); | |
| 243 } | |
| 244 | |
| 245 Future run_memory_initialAnalysis_2() async { | |
| 246 String id = 'memory-initialAnalysis-2'; | |
| 247 String description = r''' | |
| 248 1. Start server, set 'analyzer' and 'analysis_server' analysis roots. | |
| 249 2. Measure the memory usage after finishing initial analysis. | |
| 250 3. Shutdown the server. | |
| 251 4. Go to (1). | |
| 252 '''; | |
| 253 List<int> sizes = await AnalysisServerMemoryUsageTest | |
| 254 .start_waitInitialAnalysis_shutdown( | |
| 255 roots: <String>[paths.analyzer, paths.analysisServer], | |
| 256 numOfRepeats: 3); | |
| 257 printMemoryResults(id, description, sizes); | |
| 258 } | |
| 259 | |
| 260 class PathHolder { | |
| 261 String analysisServer; | |
| 262 String analyzer; | |
| 263 String flutterHelloWorld; | |
| 264 String flutterStocks; | |
| 265 | |
| 266 PathHolder({String sdkPath, String flutterPath}) { | |
| 267 analysisServer = '$sdkPath/pkg/analysis_server'; | |
| 268 analyzer = '$sdkPath/pkg/analyzer'; | |
| 269 flutterHelloWorld = '$flutterPath/examples/hello_world'; | |
| 270 flutterStocks = '$flutterPath/examples/stocks'; | |
| 271 } | |
| 272 } | |
| OLD | NEW |