Dart Documentationangular.perfDevToolsTimelineProfiler

DevToolsTimelineProfiler class

class DevToolsTimelineProfiler extends Profiler {
 final dom.Console console = dom.window.console;
 String prefix = '';

 int startTimer(String name, [String extraData]) {
   console.time('$prefix$name');
   prefix = '$prefix  ';
 }

 void stopTimer(dynamic name) {
   prefix = prefix.length > 0 ? prefix.substring(0, prefix.length - 2) : prefix;
   console.timeEnd('$prefix$name');
 }

 void markTime(String name, [String extraData]) {
   console.timeStamp('$prefix$name');
 }
}

Extends

Profiler > DevToolsTimelineProfiler

Properties

final Console console #

final dom.Console console = dom.window.console

String prefix #

String prefix = ''

Methods

void markTime(String name, [String extraData]) #

A simple zero-duration marker.

docs inherited from Profiler
void markTime(String name, [String extraData]) {
 console.timeStamp('$prefix$name');
}

int startTimer(String name, [String extraData]) #

Starts a new timer for a given action name. An int timer id will be returned which can be used in stopTimer to stop the timer.

extraData is additional information about the timed action. Implementing profiler should not assume any semantic or syntactic structure of that data and is free to ignore it in aggregate reports.

docs inherited from Profiler
int startTimer(String name, [String extraData]) {
 console.time('$prefix$name');
 prefix = '$prefix  ';
}

void stopTimer(name) #

Stop a timer for a given idOrName. If idOrName is int then it's treated as an action identifier returned from startTimer. If id is invalid or timer for that id was already stopped then ProfilerError will be thrown. If idOrName is String then the latest active timer with that name will be stopped. If no active timer exists then ProfilerError will be thrown.

docs inherited from Profiler
void stopTimer(dynamic name) {
 prefix = prefix.length > 0 ? prefix.substring(0, prefix.length - 2) : prefix;
 console.timeEnd('$prefix$name');
}

dynamic time(String name, functionOrFuture, [String extraData]) #

inherited from Profiler

Times execution of the functionOrFuture. Body can either be a no argument function or a Future. If function, it is executed synchronously and its return value is returned. If it's a Future, then timing is stopped when the future completes either successfully or with error.

dynamic time(String name, functionOrFuture, [String extraData]) {
 var id = startTimer(name, extraData);
 if (functionOrFuture is Function) {
   try {
     return functionOrFuture();
   } finally {
     stopTimer(id);
   }
 }
 if (functionOrFuture is Future) {
   return functionOrFuture.then(
       (v) {
         stopTimer(id);
         return v;
       },
       onError: (e) {
         stopTimer(id);
         throw e;
       });
 }
 throw new ProfilerError(
     'Invalid functionOrFuture or type ${functionOrFuture.runtimeType}');
}