How to find out which instruction lasts longer? (to increase the performance of my program)

I need to know how I can get each command duration so that I can maintain code to improve the performance of my program.

+4
source share
9 answers

Use a profiler. If you have a Visual Studio Team System, there is one. Otherwise, see ANTS or dotTrace .

+13
source

what you are looking for is a profiler that I think :)

see Profiler and List of Performance Analysis Tools

+2
source

To do this, you need an application profiler, it shows which code takes time.

+1
source

For this you need to use a profiler. There are several profilers, some of which are free.

My preferences are for Red Gate Ants .

+1
source

I do not think that you should go to the level of instructions for measuring bottlenecks. Micro-optimization can be harmful. You must move on to profiling the function. If you are using VS2005 or 2008, you can use

  • Performance Wizard
  • CLR profiler

to profile your functions.

As an alternative, I personally recommend using Ants Profiler

+1
source

Since Ants and dotTrace are very good, but commercial tools (I would not call them expensive - they cost money), I recently heard about the EQATEC Profiler , which is free. Did not try this due to lack of time, but maybe you want to try.

(no, I'm not related to them)

+1
source

If you have an application running and want to improve its performance using a profiler (.net or database), it is necessary that. DotTrace and Ants are known for good reasons.

If you use SQL Server, the SQL Server Profiler is a great tool for tracking and viewing what is happening on the server side of your application.

If you want to decide which approach is best to use, you can use ILDASM to parse your code in IL and see what happens under the hood. Although this is not an easy task, but I think it is worth it.

0
source

Perhaps you should take a look at FxCop , may give you some more tips on what can be improved. (Oh, and it's free!)

0
source

I am surprised that no one has mentioned this, but if you want to know the cost of individual instructions, see them here or here .

The cost of individual instructions depends on the processor, but both AMD and Intel (and any other CPU manufacturer) document this.

The problem is that costing instructions is not easy. You have many indicators that should be considered: there is latency, whether it is pipelined (in whole or in part), how large the instruction is (affects the cache of instructions), and so on. Thus, this information is really useful if you write one function that is really sensitive to performance, in which you either write the assembly yourself or carefully read the ASM created by the compiler to find and eliminate the inefficiency. And if you know well how the CPU works.

But before you get to this point, you must use a profiler like everyone else. This will help you narrow down the time spent and what needs to be optimized.

0
source

All Articles