measure time taken to run code

31 May 2011

Is it possible to measure the time taken for the mbed to run through my code.

Ideally I'd like to be able to find the time in ms for the code to run.

31 May 2011

Either you use timer:

#include "mbed.h"

Timer t;

int main() {
    t.start();
    printf("Hello World!\n");
    t.stop();
    printf("The time taken was %f seconds\n", t.read());
}

or for very short routines use "benchmark" from the cookbook: http://mbed.org/users/igor_m/programs/benchmark/lj12hn