LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to calculate how many times a function runs????? (https://www.linuxquestions.org/questions/programming-9/how-to-calculate-how-many-times-a-function-runs-904871/)

neyshule 09-24-2011 11:43 PM

How to calculate how many times a function runs?????
 
Hi all:
I have a function in a kernel module and I want to see how many times it is called and runs per second. I add a counter in the function so once it runs, counter+=1; is there any timer or something which can check this counter every second???Thanks very much.

rigor 09-25-2011 01:03 AM

The answer depends on what programming language it is, with which you are writing the code.
Did I perhaps miss in your question, someplace where you gave us that information?

neyshule 09-25-2011 10:10 AM

Quote:

Originally Posted by kakaka (Post 4481550)
The answer depends on what programming language it is, with which you are writing the code.
Did I perhaps miss in your question, someplace where you gave us that information?

I'm writing a kernel function so I use c++/c.

ambrop7 09-25-2011 01:02 PM

Use timers provided by the Linux kernel. First Google hit for "linux kernel timer" gives http://makelinux.com/ldd3/chp-7-sect-4 .


All times are GMT -5. The time now is 12:16 AM.