How to measure elapsed time using a timer

  • version

    1.1.1

  • scope

    Example.

    This code is provided as example code for a user to base their code on.

  • description

    How to measure elapsed time using a timer

  • boards

    Unless otherwise specified, this example runs on the SliceKIT Core Board, but can easily be run on any XMOS device by using a different XN file.

Timers can be used to measure the amount of time elapsed between two statements. First input the current time from the timer:

t :> start_time;

After performing the action you wish to time, input the time from the timer again:

t :> end_time;

The difference between the two times gives you the number of timer ticks elapsed.

printstr("Number of timer ticks elapsed: ");
printintln(end_time - start_time);

This method can be used to measure durations of up to 232 -1 timer ticks (approximately 42 seconds).