[ACCEPTED]-How to know which instruction taking the longest time to finish ? (to increase my program performance)-c#

Accepted answer
Score: 13

Use a profiler. If you have Visual Studio 2 Team System, there's one included. Otherwise 1 take a look at ANTS or dotTrace.

Score: 2

what you're looking for is a profiler I 1 believe :)

see: Profiler and List of Performance Analysis Tools

Score: 1

You want an application profiler for that, it 1 shows exactly what code takes how long.

Score: 1

You need to use a profiler to accomplish 2 this. It exists several profilers, some 1 are free.

My preference goes to Red Gate Ants.

Score: 1

I dont think you should go upto level of 6 instructions to measure performance bottlenecks. Micro 5 optimization can be harmful. You should 4 go up to function profiling. If you are 3 using VS2005 or 2008 you can use

  1. Performance wizard
  2. CLR profiler

to profile 2 your functions.

Alternatly I personally 1 recomend using Ants Profiler

Score: 1

Since Ants and dotTrace are very good but 6 commercial tools (I wouldn't call them expensive 5 - they're worth the money), I recently heard 4 about the EQATEC Profiler, which is free of charge. Did 3 not try it because of lack of time, but 2 maybe you want to give it a try.

(no, I am 1 not affiliated with them)

Score: 0

If you have an application running and you 11 want to improve its performance using a 10 profiler (.net or database) is a must .DotTrace 9 and Ants are famous ones for good reasons.

If 8 you are using SQL Server ,SQL server profiler 7 is a great tool to trace and watch what's 6 going on ,on the server side of your application.

If 5 you want to decide what approach is better 4 to use you can use ILDASM to disassemble 3 your code to IL and see what's going on 2 under the hood Although it's not a simple 1 task but I think it worth it.

Score: 0

You might want to take a look at FxCop as well, might 2 give you some more vauge hints as to what could 1 be improved. (Oh, and it's free!)

Score: 0

I'm surprised no one have mentioned this 22 yet, but if you want to know the cost of 21 individual instructions, look them up here or 20 here.

The cost of individual instructions varies 19 between CPU's, but both AMD and Intel (and 18 any other CPU maker) documents this.

The 17 problem is that determining the cost of 16 instructions is not straightforward. You 15 have a lot of metrics to consider: There's 14 the latency, whether it is pipelined (fully 13 or partially), how big the instruction is 12 (affects instruction cache) and so on. So 11 this information is only really helpful 10 if you're writing a single really performance-sensitive 9 function where you're either writing assembly 8 yourself, or closely reading the compiler-generated 7 ASM to find and eliminate inefficiencies. And 6 if you know a fair bit about how the CPU 5 works.

But before you get to this point, you 4 should use a profiler as everyone else have 3 suggested. That helps you narrow down where 2 the time is being spent, and what needs 1 optimizing.

More Related questions