How to measure time taken by a function

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

How to measure time taken by a function

2,576件の閲覧回数
sna9
Contributor I

Hello, 

I need to measure the number of cycles or execution time spent on a function. I tried to use the normal clock() function after including the <time.h> library and got errors and i'm starting to think that using the clock() function won't lead to any results.

I am a beginner and i would appreciate any help or hint possible.

I'm using the S32 Design Studio for ARM along with the S32K144 EVB.

ラベル(2)
タグ(3)
0 件の賞賛
返信
2 返答(返信)

2,123件の閲覧回数
mikedoidge
NXP Employee
NXP Employee

Hello,

Another method would be to toggle a pin at the start and end of the function. You can measure this with an oscilloscope. To get exact numbers, you will need to subtract the time for the pin toggling commands, but this is perhaps the easiest method.

Mike

2,123件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

you can use for example FlexTimer module. Good starting point is the FTM_s32k144 example:

pastedImage_1.png

Jiri