mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 17:59:39 +00:00
Sped up Timeline.*Sync. (~20% faster when supplying parameters)
Change-Id: Iaf0fd5ae2237e0f504d06aac8891e97feb1ae778 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233652 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
2b8051d564
commit
95a12995b8
|
@ -109,13 +109,7 @@ class Timeline {
|
|||
_stack.add(null);
|
||||
return;
|
||||
}
|
||||
var block = new _SyncBlock._(name);
|
||||
if (arguments != null) {
|
||||
block._arguments = arguments;
|
||||
}
|
||||
if (flow != null) {
|
||||
block.flow = flow;
|
||||
}
|
||||
var block = new _SyncBlock._(name, arguments: arguments, flow: flow);
|
||||
_stack.add(block);
|
||||
block._startSync();
|
||||
}
|
||||
|
@ -125,7 +119,7 @@ class Timeline {
|
|||
if (!_hasTimeline) {
|
||||
return;
|
||||
}
|
||||
if (_stack.length == 0) {
|
||||
if (_stack.isEmpty) {
|
||||
throw new StateError('Uneven calls to startSync and finishSync');
|
||||
}
|
||||
// Pop top item off of stack.
|
||||
|
@ -340,32 +334,31 @@ class _SyncBlock {
|
|||
|
||||
/// An (optional) set of arguments which will be serialized to JSON and
|
||||
/// associated with this block.
|
||||
Map? _arguments;
|
||||
final Map? arguments;
|
||||
|
||||
/// An (optional) flow event associated with this block.
|
||||
Flow? _flow;
|
||||
final Flow? flow;
|
||||
|
||||
_SyncBlock._(this.name);
|
||||
late final String _jsonArguments = _argumentsAsJson(arguments);
|
||||
|
||||
_SyncBlock._(this.name, {this.arguments, this.flow});
|
||||
|
||||
/// Start this block of time.
|
||||
void _startSync() {
|
||||
_reportTaskEvent(0, 'B', category, name, _argumentsAsJson(_arguments));
|
||||
_reportTaskEvent(0, 'B', category, name, _jsonArguments);
|
||||
}
|
||||
|
||||
/// Finish this block of time. At this point, this block can no longer be
|
||||
/// used.
|
||||
void finish() {
|
||||
// Report event to runtime.
|
||||
_reportTaskEvent(0, 'E', category, name, _argumentsAsJson(_arguments));
|
||||
if (_flow != null) {
|
||||
_reportFlowEvent(category, "${_flow!.id}", _flow!._type, _flow!.id,
|
||||
_reportTaskEvent(0, 'E', category, name, _jsonArguments);
|
||||
final Flow? tempFlow = flow;
|
||||
if (tempFlow != null) {
|
||||
_reportFlowEvent(category, "${tempFlow.id}", tempFlow._type, tempFlow.id,
|
||||
_argumentsAsJson(null));
|
||||
}
|
||||
}
|
||||
|
||||
void set flow(Flow f) {
|
||||
_flow = f;
|
||||
}
|
||||
}
|
||||
|
||||
String _argumentsAsJson(Map? arguments) {
|
||||
|
|
Loading…
Reference in a new issue