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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
3,444件の閲覧回数
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

ラベル(3)
0 件の賞賛
返信
1 解決策
2,428件の閲覧回数
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 件の賞賛
返信
4 返答(返信)
2,429件の閲覧回数
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 件の賞賛
返信
2,428件の閲覧回数
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 件の賞賛
返信
2,428件の閲覧回数
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 件の賞賛
返信
2,428件の閲覧回数
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport can you help with this case?

0 件の賞賛
返信