Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart is there a way to measure execution time for a small code

Tags:

dart

I've made some snippet involving parsing a html and wants to know if the code runs slow or not, is this doable?

like image 838
Faris Nasution Avatar asked Jun 06 '13 06:06

Faris Nasution


People also ask

How do I check my response time in flutter?

You need to run your app in debug mode then open DevTools and go to the Network Panel to see them.

How is execution time calculated in microcontroller?

By using 20MHZ crystal oscillator, it would be around 200 ns per period. SO it's 200ns*4 Tosc = 800ns/instruction. Since, i write the code in c language , then i compile the program and downloading the HEX file in microcontroller and it works//executes.


1 Answers

You can use Stopwatch to measure execution time :

Stopwatch stopwatch = new Stopwatch()..start(); doSomething(); print('doSomething() executed in ${stopwatch.elapsed}'); 

Dart 2:

  • Type inference
  • Optional new
final stopwatch = Stopwatch()..start(); doSomething(); print('doSomething() executed in ${stopwatch.elapsed}'); 
like image 157
Alexandre Ardhuin Avatar answered Sep 19 '22 16:09

Alexandre Ardhuin