The best way to measure the speed of functions, classes, and processes

What is the best way to measure the speed of functions and classes? There are different solutions for each function, and I would like to know how to measure the speed of work and optimize my general classes with the best possible solution.

Also, how do you measure SQL speed, for example, differences between stored procedures, selections, views, etc.?

+3
source share
3 answers

You have two options.

Use System.Diagnostics.Stopwatchfor certain methods.

This is a high-resolution timer in .NET that you can use for specific parts of your code.

Use a profiler if you need to measure performance for your entire application.

Ultra- Visual Studio , EQATEC.

+4

. (, Stopwatch) , , . , - , . , . , , .

, , , .

+1

. . , , , .

, , - , . , , (, - 1000 ) .

, . . , .

- , . () (I/O). - .

  • , , ( , , ), , , , . , .

To find them, I think fetching a stopwatch on the stack is the best way. There is no need to be an efficient process for this, and a fairly small number of samples work just as well (or better) than a large number of samples. This must be done many times, because any given program, as written at the beginning, does not contain only one possibility for acceleration. It contains several. Here is an example.

0
source

Source: https://habr.com/ru/post/1789693/


All Articles