How to measure time taken by a function

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

How to measure time taken by a function

1,509 Views
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.

Labels (2)
Tags (3)
0 Kudos
2 Replies

1,056 Views
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

1,056 Views
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