This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x precision time interval measurement using ordinary kernel functions



Hi

I need to measure the total time for EDMA transfer  600Kbytes, from GPMC to a kernel buffer.

Which is the recommended method using ordinary functions available in kernel linux?

Which precision is possible? Milliseconds? Microseconds?

Examples available?

Sergio

  • Hi Sergio,

    A possible way to measure time in Linux is by using clock() function. Example:

    #include <time.h>

    ......

    clock_t begin, end;
    begin = clock();

    // Your code

    end = clock();
    difference = (end-begin)/CLOCKS_PER_SECOND;

    The precision depends on the value of CLOCKS_PER_SECOND macro.



    BR
    Tsvetolin Shulev

  • Sergio,

    One more time measurement way with precision in microseconds is using gettimeofday function. Sometimes in the worst case the real precision is tens microseconds.

    #include <sys/time.h>

    struct timeval start_time, end_time;

    gettimeofday(&start_time, 0);
    /*
    Your code should be here
    */
    gettimeofday(&end_time, 0);
    long elapsed = (end_time.tv_sec-start_time.tv_sec)*1000000 + end_time.tv_usec-start_time.tv_usec;

    elapsed value is measured in microseconds.

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev

    Yes, the second method worked very fine for me. I can measure the time in microseconds resolution.

    Thanks a lot.

    Sergio