How to measure a C functions execution time in ARM DS-5 under Timesys Linux?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to measure a C functions execution time in ARM DS-5 under Timesys Linux?

Jump to solution
2,501 Views
dragan
Contributor III

Respected Colleagues,

can somebody share a sample how to measure execution time inside the ARM DS-5 GCC application for Vybrid VF61 A5 core, because generic way (shown bellow) doesn't work. Variable clock_t can not be linked to a code no matter that the time.h is included. Result is always zero.

#include <time.h>

clock_t start, end;
double cpu_time_used;

start
= clock();
... /* Do the work. */
end
= clock();
cpu_time_used
= ((double) (end - start)) / CLOCKS_PER_SEC;


Thanks in advance.


With best regards,

Dragan Kujovic

Labels (3)
0 Kudos
1 Solution
1,485 Views
timesyssupport
Senior Contributor II

Hello Dragan,

We have verified your code with our Timesys toolchain ,clock function works as expected. Between the two successive clock functions, if you do the work with less  than 1 unity i.e it executes in microseconds, will return zero. You can verify this with the precision of 10 floating point values in printf statement.

printf("cpu time used is %.10f \n",cpu_time_used);

Also you can try with gettimeofday() to get the execution time of your function.

Thanks,

Timesys Support

View solution in original post

0 Kudos
4 Replies
1,486 Views
timesyssupport
Senior Contributor II

Hello Dragan,

We have verified your code with our Timesys toolchain ,clock function works as expected. Between the two successive clock functions, if you do the work with less  than 1 unity i.e it executes in microseconds, will return zero. You can verify this with the precision of 10 floating point values in printf statement.

printf("cpu time used is %.10f \n",cpu_time_used);

Also you can try with gettimeofday() to get the execution time of your function.

Thanks,

Timesys Support

0 Kudos
1,485 Views
dragan
Contributor III

Thanks for your answer.

I think that something is wrong with project and compiling from ARM DS-5, because the variable clock_t is red underscored, but compiling pass without errors and warnings. time.h is included.

When I try from Linux shell "time sleep 2" it returns correct answer, but when I try it from application with reading

start = clock();

sleep(2); // 2 seconds

end = clock();

both start and end are populated with the same value, and because of that the result is allways zero.

I will try to further investigate this.

With best regards,

Dragan Kujovic

0 Kudos
1,485 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi Dragan,

" I think that something is wrong with project and compiling from ARM DS-5, because the variable clock_t is red underscored, but compiling pass without errors and warnings. time.h is included."

Those problems in DS-5 are due the IDE is not able to find some symbols. You have to #include the correct file including the path.

Best Regards,

Alejandro

0 Kudos
1,485 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport can you help with this case?

0 Kudos