I have as an example this block of code :
for(int index = 0; index < 1000000; index =1) {
print(i);
}
is there any way to measure the time/duration taken by this to finish in the milliseconds
without using external source, I mean any idea to do it in the dart ?
CodePudding user response:
You can use the Stopwatch
class which makes it easy to measure time:
void main() {
Stopwatch stopWatch = Stopwatch()..start();
for(int index = 0; index < 1000000; index =1) {
print(index);
}
print('Time it took: ${stopWatch.elapsedMilliseconds}ms');
}