How is profiling different from registration?

How is profiling different from logging?

Is it just that profiling is used to measure performance to find out how long each function takes? Or am I disconnected?

Typically, how are profiling libraries used?

What types of statistics are obtained by profiling?

+7
profiling logging
source share
8 answers

Logging tells you what happened. This is great for forensics and debugging.

Profiling calculates that: it tells you how much time was spent on your code in each area or how many times the code body was executed. This helps you improve the performance of your code.

Profiling usually works at the level of a line of code, a function call, or sometimes a file. For each level, he usually can tell you:

  • How many times a block has been executed. As a rule, it is less important to optimize rarely used code than code that runs millions of times. One exception is code that forces the user (or another process) to wait for it to complete.

  • How many times a branch has been made, say in an if or switch . Again, you tend to care most about optimizing frequently used code.

  • How much time was spent on a particular function. Warning: even experienced developers are often surprised by these results. It’s very difficult to predict where your “time plunges”.

  • How much time was spent on the function and on all the functions called inside this function. Perhaps this is not the function itself, but its children, who need optimization.

  • How many times the device was called by each subscriber. You may find that a particular function is called primarily from an unexpected place.

Armed with the data of a good profiler, you can often achieve significant performance improvements with relatively little effort.

+20
source share

Profiling focuses on defining performance with respect to function / method calls, e.g.

  • Function time spent
  • Time spent on functions + time spent on child functions.
  • The number of times a particular function is called

The whole idea of ​​profiling is a good overview of the system to determine where optimization can be done. If you know that a particular function is called 20 more times than the second, most called function, you know when to focus on optimization.

It also shows where you are not wasting your time. You do not want to spend a day optimizing a function that is called only once per hour. You want to focus on optimizing those functions that are called several times per second.

The record , in my understanding, simply tracks what was triggered (but without the detailed metadata associated with each call).

Profiling libraries, such as Rational Quantify, by programming code to collect statistics as it runs. This will have an implicit performance impact, but it will be relative throughout the system.

+3
source share

Profiling is used to determine the effectiveness of program execution time. It can be used to measure memory usage or CPU usage. You can use it to optimize your code.

Registration, on the other hand, is an audit function. You want to see what the program did during its operation. It is more used for debugging than performance.

+2
source share

I see profiling as a measurement of performance, and you do not need to analyze every part of the code, sometimes it is better to focus on certain areas.

Logging is the storage of information for future use, information that may be related to profiling, but not necessarily. It could just be a log of what happened.

All the profiling materials I have ever used basically allow you to store the start and end times of a “transaction” and then process the data to see which takes the most time.

+1
source share

Logging is a record of what has been done to audit or troubleshoot. Profiling, I would say, is a method of evaluating performance. Profiling can be done by registering performance indicators, or it can be done using specialized tools or utilities to check the status of the system as it starts.

+1
source share

Log statements are usually written in the source code itself, while profiling you can change the code after compiling it and , then and only for the profiling session (i.e., in any verification of the assembly itself there is no profiling code) and calibration performance in real time, or it can be chosen so that it can track the performance in a less granular, but less intrusive way.

+1
source share

The log tells you how many questions you sent to stackoverflow.

Profiling tells you how much time is required to publish each question and how much of your working day you spend here.

+1
source share

The previous answers are correct.

However, IMHO, profilers have more smoke than guns, and I am sure that this causes some arrows to be pressed.

If you want to know how long a function answers, you need to know how many times it is called and how long it takes when it is called. One of them is useless without the other.

Even if he tells you both, he does not tell you which statements within the function are responsible for the time. They tell you a lot of things, such as annotated call schedules and much more, but they are still in the form of a lot of clues that you need to solve, making your assumptions more “informed”.

Then they talk about how the "exact" numbers are. Makes a pleasant presentation, but does not fix the problem.

What they can do (and they do not) indicates specific instructions or instructions and will say

This exact statement right here, if you could get rid of it, will save you X% of the total execution time.

and sort them by X.

If you really need to fix a performance problem, this is what you need, and you can easily get it yourself. See here:
How to optimize the performance of your program

+1
source share

All Articles