execution_timer

Creator: coderz1093

Last updated:

Add to Cart

Description:

execution timer

execution_timer #


Table of Contents

Introduction
Using the Library


Introduction #
Provides a simple way to time parts of code as they execute in real, clock,
time.
Using the Library #
Add the repo to your Dart pubspec.yaml file.
dependencies:
execution_timer: <<version>>
copied to clipboard
Then run...
dart pub get
copied to clipboard
By default, the timing is enabled in debug mode but disabled in production mode.
To change this set TimeKeeper.enabled to be true or false. Since this
is not a Flutter library, it can be used in any Dart base application, but it
cannot detect Profile mode vs Debug.
There are two ways to perform a time measurement.

Use the ExecutionWatch and ExecutionTimer to manually measure your timing:
// This option will be more performant for loops like the following...

final watch = ExecutionWatch(group: 'myGroup', name: 'myTimerName');

for (var i = 0; i < someCount; i++) {
final timer = watch.start();
// do something worth measuring
timer.stop();
}

// each iteration from the loop will be individually timed
copied to clipboard

Use the TimeKeeper.measure function:
// This option may be easier for timing long-ish running units of work with
// return values.

final result = await TimeKeeper.measure<X>(
'myTimerName',
(timer) async {
X result;

// doSomething that assigns X to the result

return result;
},
group: 'myOptionalGroupName',
);
copied to clipboard


When you need the results, you can get them from:
final timings = TimeKeeper.toJson();

print(const JsonEncoder.withIndent(' ').convert(timings));
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.