Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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.local; | 5 library server.performance.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 | 10 |
| 11 import 'benchmark_scenario.dart'; | 11 import 'benchmark_scenario.dart'; |
| 12 import 'memory_tests.dart'; | |
| 12 | 13 |
| 13 main(List<String> args) async { | 14 main(List<String> args) async { |
| 14 int length = args.length; | 15 int length = args.length; |
| 15 if (length < 1) { | 16 if (length < 1) { |
| 16 print( | 17 print( |
| 17 'Usage: dart benchmark_local.dart path_to_sdk_checkout [path_to_flutter_ checkout]'); | 18 'Usage: dart benchmark_local.dart path_to_sdk_checkout [path_to_flutter_ checkout]'); |
| 18 return; | 19 return; |
| 19 } else if (length == 1) { | 20 } else if (length == 1) { |
| 20 paths = new PathHolder(sdkPath: args[0]); | 21 paths = new PathHolder(sdkPath: args[0]); |
| 21 } else { | 22 } else { |
| 22 paths = new PathHolder(sdkPath: args[0], flutterPath: args[1]); | 23 paths = new PathHolder(sdkPath: args[0], flutterPath: args[1]); |
| 23 } | 24 } |
| 24 String now = new DateTime.now().toUtc().toIso8601String(); | 25 String now = new DateTime.now().toUtc().toIso8601String(); |
| 25 print('Benchmark started: $now'); | 26 print('Benchmark started: $now'); |
| 26 print(''); | 27 print(''); |
| 27 print(''); | 28 print(''); |
| 28 await run_local_initialAnalysis_1(); | 29 await run_local_initialAnalysis_1(); |
| 29 await run_local_initialAnalysis_2(); | 30 await run_local_initialAnalysis_2(); |
| 30 await run_local_initialAnalysis_3(); | 31 await run_local_initialAnalysis_3(); |
| 31 await run_local_change_1(); | 32 await run_local_change_1(); |
| 32 await run_local_change_2(); | 33 await run_local_change_2(); |
| 33 await run_local_completion_1(); | 34 await run_local_completion_1(); |
| 34 await run_local_completion_2(); | 35 await run_local_completion_2(); |
| 35 await run_local_completion_3(); | 36 await run_local_completion_3(); |
| 36 await run_local_completion_4(); | 37 await run_local_completion_4(); |
| 37 await run_local_refactoring_1(); | 38 await run_local_refactoring_1(); |
| 39 | |
| 40 await run_memory_initialAnalysis_1(); | |
| 41 await run_memory_initialAnalysis_2(); | |
| 38 } | 42 } |
| 39 | 43 |
| 40 PathHolder paths; | 44 PathHolder paths; |
| 41 | 45 |
| 42 Future run_local_change_1() async { | 46 Future run_local_change_1() async { |
| 43 String id = 'local-change-1'; | 47 String id = 'local-change-1'; |
| 44 String description = r''' | 48 String description = r''' |
| 45 1. Open 'analyzer'. | 49 1. Open 'analyzer'. |
| 46 2. Change a method body in src/task/dart.dart. | 50 2. Change a method body in src/task/dart.dart. |
| 47 3. Measure the time to finish analysis. | 51 3. Measure the time to finish analysis. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 file: '${paths.analyzer}/lib/src/context/cache.dart', | 221 file: '${paths.analyzer}/lib/src/context/cache.dart', |
| 218 fileChange: new FileChange( | 222 fileChange: new FileChange( |
| 219 afterStr: 'getState(An', afterStrBack: 3, insertStr: 'NewName'), | 223 afterStr: 'getState(An', afterStrBack: 3, insertStr: 'NewName'), |
| 220 refactoringAtStr: 'getSourcesWithFullName(String path)', | 224 refactoringAtStr: 'getSourcesWithFullName(String path)', |
| 221 refactoringKind: RefactoringKind.RENAME, | 225 refactoringKind: RefactoringKind.RENAME, |
| 222 refactoringOptions: new RenameOptions('getSourcesWithFullName2'), | 226 refactoringOptions: new RenameOptions('getSourcesWithFullName2'), |
| 223 numOfRepeats: 5); | 227 numOfRepeats: 5); |
| 224 printBenchmarkResults(id, description, times); | 228 printBenchmarkResults(id, description, times); |
| 225 } | 229 } |
| 226 | 230 |
| 231 Future run_memory_initialAnalysis_1() async { | |
| 232 String id = 'memory-initialAnalysis-1'; | |
| 233 String description = r''' | |
| 234 1. Start server, set 'analyzer' and 'analysis_server' analysis roots. | |
|
scheglov
2016/07/06 17:55:04
I as can see, we set only "analyzer" as the analys
| |
| 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 | |
| 227 class PathHolder { | 260 class PathHolder { |
| 228 String analysisServer; | 261 String analysisServer; |
| 229 String analyzer; | 262 String analyzer; |
| 230 String flutterHelloWorld; | 263 String flutterHelloWorld; |
| 231 String flutterStocks; | 264 String flutterStocks; |
| 232 | 265 |
| 233 PathHolder({String sdkPath, String flutterPath}) { | 266 PathHolder({String sdkPath, String flutterPath}) { |
| 234 analysisServer = '$sdkPath/pkg/analysis_server'; | 267 analysisServer = '$sdkPath/pkg/analysis_server'; |
| 235 analyzer = '$sdkPath/pkg/analyzer'; | 268 analyzer = '$sdkPath/pkg/analyzer'; |
| 236 flutterHelloWorld = '$flutterPath/examples/hello_world'; | 269 flutterHelloWorld = '$flutterPath/examples/hello_world'; |
| 237 flutterStocks = '$flutterPath/examples/stocks'; | 270 flutterStocks = '$flutterPath/examples/stocks'; |
| 238 } | 271 } |
| 239 } | 272 } |
| OLD | NEW |