1

I want to check time taken by each function and system calls made by each function in my project .My code is part of user as well as kernel space. So i need time taken in both space. I am interested to know performance in terms of CPU time and Disk IO. Should i use profiler tool ? if yes , which will be more preferable ? or what other option i have ?

Please help, Thanks

4

3 に答える 3

1

As for kernel level profiling or time taken by some instructions or functions could be measured in clock tics used. To get actual how many clock ticks have been used to do a given task could be measured by kernel function as...

#include <sys/time.h>
unsigned long ini,end;
rdtscl(ini);
...your code....
rdtscl(end);

printk("time lapse in cpu clics: %lu\n",(end-ini));

for more details http://www.xml.com/ldd/chapter/book/ch06.html and if your code is taking more time then you can also use jiffies effectively.

And for user-space profiling you can use various timing functions whicg give the time in nanosecond resolution or oprofile(http://oprofile.sourceforge.net/about/) & refer tis Timer function to provide time in nano seconds using C++

于 2013-01-22T13:04:03.017 に答える
1

For kernel-space function tracing and profiling (which includes a call-graph format and the time taken by individual functions), consider using the Ftrace framework.

Specifically for function profiling (within the kernel), enable the CONFIG_FUNCTION_PROFILER kernel config: under Kernel Hacking / Tracing / Kernel function profiler.

It's Help :

CONFIG_FUNCTION_PROFILER:

This option enables the kernel function profiler. A file is created
in debugfs called function_profile_enabled which defaults to zero.
When a 1 is echoed into this file profiling begins, and when a
zero is entered, profiling stops. A "functions" file is created in
the trace_stats directory; this file shows the list of functions that have been hit and their counters.

Some resources:

Documentation/trace/ftrace.txt

Secrets of the Ftrace function tracer

Using ftrace to Identify the Process Calling a Kernel Function

于 2013-01-23T13:29:15.023 に答える
0

Well I only develop in userspace so I don't know, how much this will help you with disk IO or Kernelspace profiling, but I profiled a lot with oprofile.

I haven't used it in a while, so I cannot give you a step by step guide, but you may find more informations here:

http://oprofile.sourceforge.net/doc/results.html

Usually this helped me finding my problems. You may have to play a bit with the opreport output, to get the results you want.

于 2013-01-22T11:34:44.677 に答える