How is profiling different from logging?
Is it just that profiling is used for performance measurements to see how long each function takes? Or am I off?
Typically, how are profiling libraries used?
What types of stats are obtained by profiling?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Logging tells you what happened. It’s great for forensics and debugging.
Profiling quantifies that: it tells you how much time your code spent in each area, or how many times a body of code was executed. It helps you improve your code’s performance.
Profiling typically operates at the level of a line of code, a function call, or sometimes a file. For each level, it can typically tell you:
How many times the unit was executed. It’s generally less important to optimize rarely-used code than code that executes millions of times. One exception is code that makes a user (or another process) wait for it to complete.
How many times a branch was taken, say in an
iforswitchstatement. Again, you typically care most about optimizing often-used code.How much time was spent in a particular function. Warning: even experienced developers are often surprised by these results. It’s very difficult to predict where your ‘time sinks’ are.
How much time was spent in a function and all functions called within that function. Maybe it’s not the function itself, but its children, that need optimizing.
How many times the unit was called by each caller. You may find that a particular function is called primarily from an unexpected place.
Armed with the data from a good profiler, you can often gain significant improvements in performance with relatively little effort.