Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: pkg/analysis_server/benchmark/perf/benchmark_scenario.dart

Issue 2150793003: Rework local benchmarks into benchmarks on the Flutter codebase. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/benchmark/perf/benchmark_local.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/benchmark/perf/benchmark_scenario.dart
diff --git a/pkg/analysis_server/benchmark/perf/benchmark_scenario.dart b/pkg/analysis_server/benchmark/perf/benchmark_scenario.dart
index aac844b888a5910c8117535b43799825340dcde8..3ec4c4c4730672de14502a82c5dc3755ed4859db 100644
--- a/pkg/analysis_server/benchmark/perf/benchmark_scenario.dart
+++ b/pkg/analysis_server/benchmark/perf/benchmark_scenario.dart
@@ -6,6 +6,7 @@ library server.performance.scenarios;
import 'dart:async';
import 'dart:io';
+import 'dart:math';
import 'package:analysis_server/plugin/protocol/protocol.dart';
import 'package:unittest/unittest.dart';
@@ -13,9 +14,11 @@ import 'package:unittest/unittest.dart';
import 'performance_tests.dart';
void printBenchmarkResults(String id, String description, List<int> times) {
+ int minTime = times.fold(1 << 20, min);
String now = new DateTime.now().toUtc().toIso8601String();
print('$now ========== $id');
print('times: $times');
+ print('min_time: $minTime');
print(description.trim());
print('--------------------');
print('');
@@ -185,11 +188,19 @@ class BenchmarkScenario extends AbstractTimingTest {
*/
Future<String> _applyFileChange(String file, FileChange desc) async {
String originalContent = _getFileContent(file);
- int offset = _indexOfEnd(file, originalContent, desc.afterStr);
- offset -= desc.afterStrBack;
- String updatedContent = originalContent.substring(0, offset) +
- desc.insertStr +
- originalContent.substring(offset);
+ String updatedContent;
+ if (desc.afterStr != null) {
+ int offset = _indexOfEnd(file, originalContent, desc.afterStr);
+ offset -= desc.afterStrBack;
+ updatedContent = originalContent.substring(0, offset) +
+ desc.insertStr +
+ originalContent.substring(offset);
+ } else if (desc.replaceWhat != null) {
+ int offset = _indexOf(file, originalContent, desc.replaceWhat);
+ updatedContent = originalContent.substring(0, offset) +
+ desc.replaceWith +
+ originalContent.substring(offset + desc.replaceWhat.length);
+ }
await sendAnalysisUpdateContent(
{file: new AddContentOverlay(updatedContent)});
return updatedContent;
@@ -279,9 +290,14 @@ class FileChange {
final String afterStr;
final int afterStrBack;
final String insertStr;
+ final String replaceWhat;
+ final String replaceWith;
- FileChange({this.afterStr, this.afterStrBack: 0, this.insertStr}) {
- expect(afterStr, isNotNull, reason: 'afterStr');
- expect(insertStr, isNotNull, reason: 'insertStr');
+ FileChange({this.afterStr, this.afterStrBack: 0, this.insertStr, this.replaceWhat, this.replaceWith}) {
+ if (afterStr != null) {
+ expect(insertStr, isNotNull, reason: 'insertStr');
+ } else if (replaceWhat != null) {
+ expect(replaceWith, isNotNull, reason: 'replaceWith');
+ }
}
}
« no previous file with comments | « pkg/analysis_server/benchmark/perf/benchmark_local.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698