Execution time of a specific segment of code in the kernel
Source: Internet
Author: User
For details about how to obtain the execution time of a specific segment of code in the kernel-Linux general technology-Linux programming and kernel information, see the following. Under 2.6.22, I modified the system to call the outermost kernel functions sys_read () and sys_write () corresponding to read () and write () to extend the read/write functions, now I want to test the extra time consumption caused by the extended functions.
My idea is to take the current time at the start of the function code, and then take the end time, then calculate the difference, and accumulate. The method is as follows:
Unsigned long starttime, finishtime;
Startime = jiffies/HZ; // The start time is the current time.
Finishtime = jiffies/HZ; // The end time is the current time.
Printk ("syc_seconds = % d \ nNow totaluse = % d", finishtime-starttime, totalpolicime );
(The totalpolicime variable is placed outside the function to become a global variable)
However, the recorded time in this method is always 0.
Is there a problem with my thoughts? In the kernel, how should we get the current time at a certain time point and record the execution time of a piece of code?
Hope you can solve this problem. thank you very much!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.