How to measure time taken by a function

cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure time taken by a function

461 Views
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

8 Views
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

8 Views
NXP Employee
NXP Employee

Hi, 

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

pastedImage_1.png

Jiri