mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
rename TracingCategory to TimelineStream (#3822)
This commit is contained in:
parent
36d437d6f2
commit
770f8f1d0c
@ -80,10 +80,10 @@ void main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
categories: const <TracingCategory>[
|
streams: const <TimelineStream>[
|
||||||
TracingCategory.dart,
|
TimelineStream.dart,
|
||||||
TracingCategory.gc,
|
TimelineStream.gc,
|
||||||
TracingCategory.compiler
|
TimelineStream.compiler
|
||||||
]);
|
]);
|
||||||
new TimelineSummary.summarize(timeline)
|
new TimelineSummary.summarize(timeline)
|
||||||
..writeSummaryToFile('transitions_perf', pretty: true)
|
..writeSummaryToFile('transitions_perf', pretty: true)
|
||||||
|
@ -16,7 +16,7 @@ export 'src/driver.dart' show
|
|||||||
CommonFinders,
|
CommonFinders,
|
||||||
EvaluatorFunction,
|
EvaluatorFunction,
|
||||||
FlutterDriver,
|
FlutterDriver,
|
||||||
TracingCategory;
|
TimelineStream;
|
||||||
|
|
||||||
export 'src/error.dart' show
|
export 'src/error.dart' show
|
||||||
DriverError,
|
DriverError,
|
||||||
|
@ -15,27 +15,27 @@ import 'health.dart';
|
|||||||
import 'message.dart';
|
import 'message.dart';
|
||||||
import 'timeline.dart';
|
import 'timeline.dart';
|
||||||
|
|
||||||
enum TracingCategory {
|
enum TimelineStream {
|
||||||
all, api, compiler, dart, debugger, embedder, gc, isolate, vm
|
all, api, compiler, dart, debugger, embedder, gc, isolate, vm
|
||||||
}
|
}
|
||||||
|
|
||||||
const List<TracingCategory> _defaultCategories = const <TracingCategory>[TracingCategory.all];
|
const List<TimelineStream> _defaultStreams = const <TimelineStream>[TimelineStream.all];
|
||||||
|
|
||||||
// See https://github.com/dart-lang/sdk/blob/master/runtime/vm/timeline.cc#L32
|
// See https://github.com/dart-lang/sdk/blob/master/runtime/vm/timeline.cc#L32
|
||||||
String _tracingCategoriesToString(List<TracingCategory> categories) {
|
String _timelineStreamsToString(List<TimelineStream> streams) {
|
||||||
final String contents = categories.map((TracingCategory category) {
|
final String contents = streams.map((TimelineStream stream) {
|
||||||
switch(category) {
|
switch(stream) {
|
||||||
case TracingCategory.all: return 'all';
|
case TimelineStream.all: return 'all';
|
||||||
case TracingCategory.api: return 'API';
|
case TimelineStream.api: return 'API';
|
||||||
case TracingCategory.compiler: return 'Compiler';
|
case TimelineStream.compiler: return 'Compiler';
|
||||||
case TracingCategory.dart: return 'Dart';
|
case TimelineStream.dart: return 'Dart';
|
||||||
case TracingCategory.debugger: return 'Debugger';
|
case TimelineStream.debugger: return 'Debugger';
|
||||||
case TracingCategory.embedder: return 'Embedder';
|
case TimelineStream.embedder: return 'Embedder';
|
||||||
case TracingCategory.gc: return 'GC';
|
case TimelineStream.gc: return 'GC';
|
||||||
case TracingCategory.isolate: return 'Isolate';
|
case TimelineStream.isolate: return 'Isolate';
|
||||||
case TracingCategory.vm: return 'VM';
|
case TimelineStream.vm: return 'VM';
|
||||||
default:
|
default:
|
||||||
throw 'Unknown tracing category $category';
|
throw 'Unknown timeline stream $stream';
|
||||||
}
|
}
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
return '[$contents]';
|
return '[$contents]';
|
||||||
@ -249,11 +249,11 @@ class FlutterDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Starts recording performance traces.
|
/// Starts recording performance traces.
|
||||||
Future<Null> startTracing({List<TracingCategory> categories: _defaultCategories}) async {
|
Future<Null> startTracing({List<TimelineStream> streams: _defaultStreams}) async {
|
||||||
assert(categories != null && categories.length > 0);
|
assert(streams != null && streams.length > 0);
|
||||||
try {
|
try {
|
||||||
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, <String, String>{
|
await _peer.sendRequest(_kSetVMTimelineFlagsMethod, <String, String>{
|
||||||
'recordedStreams': _tracingCategoriesToString(categories)
|
'recordedStreams': _timelineStreamsToString(streams)
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
} catch(error, stackTrace) {
|
} catch(error, stackTrace) {
|
||||||
@ -286,8 +286,8 @@ class FlutterDriver {
|
|||||||
///
|
///
|
||||||
/// This is merely a convenience wrapper on top of [startTracing] and
|
/// This is merely a convenience wrapper on top of [startTracing] and
|
||||||
/// [stopTracingAndDownloadTimeline].
|
/// [stopTracingAndDownloadTimeline].
|
||||||
Future<Timeline> traceAction(Future<dynamic> action(), { List<TracingCategory> categories: _defaultCategories }) async {
|
Future<Timeline> traceAction(Future<dynamic> action(), { List<TimelineStream> streams: _defaultStreams }) async {
|
||||||
await startTracing(categories: categories);
|
await startTracing(streams: streams);
|
||||||
await action();
|
await action();
|
||||||
return stopTracingAndDownloadTimeline();
|
return stopTracingAndDownloadTimeline();
|
||||||
}
|
}
|
||||||
|
@ -236,8 +236,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('traceAction categories', () {
|
group('traceAction with timeline streams', () {
|
||||||
test('specify non-default categories', () async {
|
test('specify non-default timeline streams', () async {
|
||||||
bool actionCalled = false;
|
bool actionCalled = false;
|
||||||
bool startTracingCalled = false;
|
bool startTracingCalled = false;
|
||||||
bool stopTracingCalled = false;
|
bool stopTracingCalled = false;
|
||||||
@ -267,10 +267,10 @@ void main() {
|
|||||||
Timeline timeline = await driver.traceAction(() {
|
Timeline timeline = await driver.traceAction(() {
|
||||||
actionCalled = true;
|
actionCalled = true;
|
||||||
},
|
},
|
||||||
categories: const <TracingCategory>[
|
streams: const <TimelineStream>[
|
||||||
TracingCategory.dart,
|
TimelineStream.dart,
|
||||||
TracingCategory.gc,
|
TimelineStream.gc,
|
||||||
TracingCategory.compiler
|
TimelineStream.compiler
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(actionCalled, isTrue);
|
expect(actionCalled, isTrue);
|
||||||
|
Loading…
Reference in New Issue
Block a user