Microsoft make this piece of software called "Visual Studio 2008 Professional". I have found that there doesn't appear to be an application performance profiler or something similar in it, making it seem not so "professional" to me.
If Microsoft don't include a profiler, what are your third party options for time profiling for Visual Studio 2008? Free would be preferable, as this is for uni student purposes :P
There are a couple of free profilers, not as complete or polished as the commercial ones, but they can definately help a lot:
Eqatec - This was designed for Windows CE, but works just fine for normal applications.
Soft Prodigy Profile Sharp - This is actually an open source project written in c#, so you can tinker with it if you want.
Personally, I use the Red Gate profiler.
Others swear by the JetBrains one.
Those seem to be the options, and there isn't much between them.
I use JetBrains dotTrace profiler. This is a commercial profiler. (Full disclosure: I receive a free licence as an MVP. It has proved very useful though.)
There's also the free CLR Profiler for .NET 2.0 and an article explaining how to use it.
I use the Team System Edition. That comes with a profiler which is pretty good. There are other options out there:
Rational Purify (there's this PurifyPlus, but dunno much)
Intel Vtune
Hope that helps. Note: None of them are free.
Happy profiling :)
Download the VS 2008 stand alone command line profiler
http://www.microsoft.com/downloads/details.aspx?familyid=fd02c7d6-5306-41f2-a1be-b7dcb74c9c0b&displaylang=en
RedGate ANTS profiler is not that expensive, and does the job.
I use JetBrain's dotTrace and it works quite well.
same answer as:
Re-edited: You asked what your options were. If your heart is set on profiling, then look for a profiler.
On the other hand, if you actually have a performance problem to find, the simple method works as well or better than nearly every profiler. I say nearly every, because in some profilers you can actually tease out what you need to know, which is the time-cost attributable to individual instructions, especially call instructions.
The time-cost of an instruction is the amount of time that would be saved if the instruction could be removed, and a good estimate of it is the fraction of call stack samples containing it. You don't need to estimate that fraction with high precision. If the instruction is on 5 out of 10 samples, it's cost is probably somewhere in the range 45% to 55%. No matter - if you could get rid of it, you would save its cost.
So finding performance problems is not hard. Just take a number of call stack samples, collect the set of instructions on those samples, and rank the instructions by the fraction of samples containing them. Among the high-fraction instructions are some that you could optimize away, and you don't have to guess where they are.
I'm simplifying somewhat, because often it is helpful to examine more state information than just the call stack, to see if some work being done is really necessary. But I hope the point is made.
People express doubt that it could work in the presence of recursion, or work on large programs. A little thought (and experimentation) shows those objections do not hold water.
Related
I'm trying to understand why I can't get WPF to make my images display snappy, while startups like Facebook and Apple seem to have to trouble with making their software behave ;-)
Well, one obvious differece is that EQATEC is free, and that DotTrace isn't. However, given that usualy the free edition isn't sufficient and one has to move to the $$ ones, and given that DotTrace has a "personal license" for individual developers, this is less a differentiator than one could at first belive. And I also have Resharper...
So, leaving aside the "free" factor, is the EQATEC profiler comparable to the Jet Brains one?
EQATEC is not totally free. It just offers a free licence (note: a limited one).
I've used ANTS performance profiler, dotTrace, EQATEC, Slimtune and among memory profilers Scitech and ANTS memory profiler. Memory profilers are a different kind of beast. I found Scitech the best one, although ANTS memory profiler also offers some nice results. Among performance other profilers, ANTS and dotTrace are superior to all other known to me. Slimtune is very basic, but ... it works. EQATEC was a mixed experience.
The problem with EQATEC was that it failed to start (no matter what I tried, a crash occurred) with one of the applications I worked on, but it worked with another one although the limitations of the free version were somehow annoying.
Profilers have a steep learning curve and it takes some time to get used to one, learn to use it the right way and interpret the results correctly. So you need to put value of your time, value of the performance improvement in your application and value of the profiler into the equation and decide then. I went for ANTS.
If you rarely use it, the free/limited alternatives may do just fine. But if it should be your productivity tool, go for one of the best ones, there are trial versions available.
You can find some very good opinions here: What Are Some Good .NET Profilers?
But regarding to your profiling requirements: just pick one of those, trial or free and profile that piece of code, giving money away for such a minor profiling task is rediculous.
I'm looking for a tool to tell me how long my code takes to run. Something that would be the equivalent of recording the DateTime.Now before and after each line of code in my program, then displaying the difference between the two times for each line (after my program finishes running).
For instance, if I have a program that calls four methods in its main, I want to know (after running this tool) how long each of those methods takes to run, and then if I stepped into each method, I'd want to know how long each line in there takes to run, and so on.
Do these tools exists? Of course I'd prefer a free one, but if all that exist are professional tools then please mention those as well.
edit: it appears these tools are called Profiling tools. Thanks, this will definitely help me in my search. Unfortunately, I'm using Visual Studio 2010 Professional, so I believe the Microsoft profiling tool is out of my grasp. Any good third-party profiling tools?
You can use the CLR Profiler for .NET Framework 4
The CLR Profiler includes a number of
very useful views of the allocation
profile, including a histogram of
allocated types, allocation and call
graphs, a time line showing GCs of
various generations and the resulting
state of the managed heap after those
collections, and a call tree showing
per-method allocations and assembly
loads.
And even more profilers and tools can be found here...
More about profiling on the wikipedia
If you use the Profiler tool that come with VS it shows this to you very well. Only one down side is that I think it only comes with Ultimate. :(
Are you looking for the performance profiler? It tells you how long each function takes.
I like dotTrace, it's by the same guys that make Resharper: dotTrace
Give a try to Red Gate ANTS Performance Profiler. There's a free trial, and if you don't have access to the built-in VS2010 profiler, it does a good job.
I need to know how can I get every instruction's duration so I can maintain the code to increase the performance of my program .
Use a profiler. If you have Visual Studio Team System, there's one included. Otherwise take a look at ANTS or dotTrace.
what you're looking for is a profiler I believe :)
see: Profiler and List of Performance Analysis Tools
You want an application profiler for that, it shows exactly what code takes how long.
You need to use a profiler to accomplish this. It exists several profilers, some are free.
My preference goes to Red Gate Ants.
I dont think you should go upto level of instructions to measure performance bottlenecks. Micro optimization can be harmful. You should go up to function profiling. If you are using VS2005 or 2008 you can use
Performance wizard
CLR profiler
to profile your functions.
Alternatly I personally recomend using Ants Profiler
Since Ants and dotTrace are very good but commercial tools (I wouldn't call them expensive - they're worth the money), I recently heard about the EQATEC Profiler, which is free of charge. Did not try it because of lack of time, but maybe you want to give it a try.
(no, I am not affiliated with them)
If you have an application running and you want to improve its performance using a profiler (.net or database) is a must .DotTrace and Ants are famous ones for good reasons.
If you are using SQL Server ,SQL server profiler is a great tool to trace and watch what's going on ,on the server side of your application.
If you want to decide what approach is better to use you can use ILDASM to disassemble your code to IL and see what's going on under the hood Although it's not a simple task but I think it worth it.
You might want to take a look at FxCop as well, might give you some more vauge hints as to what could be improved. (Oh, and it's free!)
I'm surprised no one have mentioned this yet, but if you want to know the cost of individual instructions, look them up here or here.
The cost of individual instructions varies between CPU's, but both AMD and Intel (and any other CPU maker) documents this.
The problem is that determining the cost of instructions is not straightforward. You have a lot of metrics to consider: There's the latency, whether it is pipelined (fully or partially), how big the instruction is (affects instruction cache) and so on. So this information is only really helpful if you're writing a single really performance-sensitive function where you're either writing assembly yourself, or closely reading the compiler-generated ASM to find and eliminate inefficiencies. And if you know a fair bit about how the CPU works.
But before you get to this point, you should use a profiler as everyone else have suggested. That helps you narrow down where the time is being spent, and what needs optimizing.
I've not be coding long so I'm not familiar with which technique is quickest so I was wondering if there was a way to do this in VS or with a 3rd party tool?
Thanks
Profilers are great for measuring.
But your question was "How can I determine where the slow parts of my code are?".
That is a different problem. It is diagnosis, not measurement.
I know this is not a popular view, but it's true.
It is like a business that is trying to cut costs.
One approach (top down) is to measure the overall finances, then break it down by categories and departments, and try to guess what could be eliminated. That is measurement.
Another approach (bottom up) is to walk in at random into an office, pick someone at random, and ask them what they are doing at that moment and (importantly) why, in detail.
Do this more than once.
That is what Harry Truman did at the outbreak of WW2, in the US defense industry, and immediately uncovered massive fraud and waste, by visiting several sites. That is diagnosis.
In code you can do this in a very simple way: "Pause" it and ask it why it is spending that particular cycle. Usually the call stack tells you why, in detail.
Do this more than once.
This is sampling. Some profilers sample the call stack. But then for some reason they insist on summarizing time spent in each function, inclusive and exclusive. That is like summarizing by department in business, inclusive and exclusive.
It loses the information you need, which is the fine-grain detail that tells if the cycles are necessary.
To answer your question:
Just pause your program several times, and capture the call stack each time. If your code is very slow, the wasteful function calls will be on nearly every stack. They will point with precision to the "slow parts of your code".
ADDED: RedGate ANTS is getting there. It can give you cost-by-line, and it is quite spiffy. So if you're in .NET, and can spare 3 figures, and don't mind waiting around to install & learn it, it can tell you much of what your Pause key can tell you, and be much more pretty about it.
Profiling.
RedGate has a product.
JetBrains has a product.
I've used ANTS Profiler and I can join the others with recommendation.
The price is NEGLIGIBLE when you compare it with the amount of dev hours it will save you.
I you're developer for a living, and your company won't buy it for you, either change the company or buy it for yourself.
For profiling large complex UI applications then you often need a set of tools and approaches. I'll outline the approach and tools I used recently on a project to improve the performance of a .Net 2.0 UI application.
First of all I interviewed users and worked through the use cases myself to come up with a list of target use cases that highlighted the systems worse performing areas. I.e. I didn't want to spend n man days optimising a feature that was hardly ever used but very slow. I would want to spend time, however, optimising a feature that was a little bit sluggish but invoked a 1000 times a day, etc.
Once the candidate use cases were identified I instrumented my code with my own light weight logging class (I used some high performance timers and a custom logging solution because a needed sub-millisecond accuracy). You might, however, be able to get away with log4net and time stamps. The reason I instrumented code is that it is sometimes easier to read your own logs rather than the profiler's output. I needed both for a variety of reasons (e.g. measuring .Net user control layouts is not always straightforward using the profiler).
I then ran my instrumented code with the ANTS profiler and profiled the use case. By combining the ANTS profile and my own log files I was very quickly able to discover problems with our application.
We also profiled the server as well as the UI and were able to work out breakdowns for time spent in the UI, time spent on the wire, time spent on the server etc.
Also worth noting is that 1 run isn't enough, and the 1st run is usually worth throwing away. Let me explain: PC load, network traffic, JIT compilation status etc can all affect the time a particular operation will take. A simple strategy is to measure an operation n times (say 5), throw away the slowest and fastest run, the analyse the remianing profiles.
Eqatec profiler is a cute small profiler that is free and easy to use. It probably won't come anywhere near the "wow" factor of Ants profiler in terms of features but it still is very cool IMO and worth a look.
Use a profiler. ANTS costs money but is very nice.
i just set breakpoints, visual will tell you how many ms between breakpoint has passed. so you can find it manually.
ANTS Profiler is very good.
If you don't want to pay, the newer VS verions come with a profiler, but to be honest it doesn't seem very good. ATI/AMD make a free profiler... but its not very user friendly (to me, I couldn't get any useful info out of it).
The advice I would give is to time function calls yourself with code. If they are fast and you do not have a high-precision timer or the calls vary in slowness for a number of reasons (e.g. every x calls building some kind of cache), try running each one x10000 times or something, then dividing the result accordingly. This may not be perfect for some sections of code, but if you are unable to find a good, free, 3rd party solution, its pretty much what's left unless you want to pay.
Yet another option is Intel's VTune.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
What profilers have you used when working with .net programs, and which would you particularly recommend?
I have used JetBrains dotTrace and Redgate ANTS extensively. They are fairly similar in features and price. They both offer useful performance profiling and quite basic memory profiling.
dotTrace integrates with Resharper, which is really convenient, as you can profile the performance of a unit test with one click from the IDE. However, dotTrace often seems to give spurious results (e.g. saying that a method took several years to run)
I prefer the way that ANTS presents the profiling results. It shows you the source code and to the left of each line tells you how long it took to run. dotTrace just has a tree view.
EQATEC profiler is quite basic and requires you to compile special instrumented versions of your assemblies which can then be run in the EQATEC profiler. It is, however, free.
Overall I prefer ANTS for performance profiling, although if you use Resharper then the integration of dotTrace is a killer feature and means it beats ANTS in usability.
The free Microsoft CLR Profiler (.Net framework 2.0 / .Net Framework 4.0) is all you need for .NET memory profiling.
2011 Update:
The Scitech memory profiler has quite a basic UI but lots of useful information, including some information on unmanaged memory which dotTrace and ANTS lack - you might find it useful if you are doing COM interop, but I have yet to find any profiler that makes COM memory issues easy to diagnose - you usually have to break out windbg.exe.
The ANTS profiler has come on in leaps and bounds in the last few years, and its memory profiler has some truly useful features which now pushed it ahead of dotTrace as a package in my estimation. I'm lucky enough to have licenses for both, but if you are going to buy one .Net profiler for both performance and memory, make it ANTS.
Others have covered performance profiling, but with regards to memory profiling
I'm currently evaluating both the Scitech .NET Memory Profiler 3.1 and ANTS Memory Profiler 5.1 (current versions as of September 2009). I tried the JetBrains one a year or two ago and it wasn't as good as ANTS (for memory profiling) so I haven't bothered this time. From reading the web sites it looks like it doesn't have the same memory profiling features as the other two.
Both ANTS and the Scitech memory profiler have features that the other doesn't, so which is best will depend upon your preferences. Generally speaking, the Scitech one provides more detailed information while the ANTS one is really incredible at identifying the leaking object. Overall, I prefer the ANTS one because it is so quick at identifying possible leaks.
Here are the main the pros and cons of each from my experience:
Common Features of ANTS and Scitech .NET Memory Profiler
Real-time analysis feature
Excellent how-to videos on their web sites
Easy to use
Reasonably performant (obviously slower than without the profiler attached, but not so much you become frustrated)
Show instances of leaking objects
Basically they both do the job pretty well
ANTS
One-click filters to find common leaks including: objects kept alive only by event handlers, objects that are disposed but still live and objects that are only being kept alive by a reference from a disposed object. This is probably the killer feature of ANTS - finding leaks is incredibly fast because of this. In my experience, the majority of leaks are caused by event handlers not being unhooked and ANTS just takes you straight to these objects. Awesome.
Object retention graph. While the same info is available in Scitech, it's much easier to interpret in ANTS.
Shows size with children in addition to size of the object itself (but only when an instance is selected unfortunately, not in the overall class list).
Better integration to Visual Studio (right-click on graph to jump to file)
Scitech .NET Memory Profiler
Shows stack trace when object was allocated. This is really useful for objects that are allocated in lots of different places. With ANTS it is difficult to determine exactly where the leaked object was created.
Shows count of disposable objects that were not disposed. While not indicative of a leak, it does identify opportunities to fix this problem and improve your application performance as a result of faster garbage collection.
More detailed filtering options (several columns can be filtered independently).
Presents info on total objects created (including those garbage collected). ANTS only shows 'live' object stats. This makes it easier to analyze and tune overall application performance (eg. identify where lots of objects being created unnecessarily that aren't necessarily leaking).
By way of summary, I think ANTS helps you find what's leaking faster while Scitech provides a bit more detail about your overall application memory performance and individual objects once you know what to look at (eg. stack trace on creation). If the stack trace and tracking of undisposed disposable objects was added to ANTS I wouldn't see the need to use anything else.
I recently discovered EQATEC Profiler http://www.eqatec.com/tools/profiler. It works with most .NET versions and on a bunch of platforms. It is easy to use and parts of it is free, even for commercial use.
[Full Disclosure]
While not yet as full-featured as some of the other .NET memory profilers listed here, there is a new entry on the market called JustTrace. It's made by Telerik and it's primary goal is to make tracing/profiling easier and faster to do for all types of apps (web/Silverlight/desktop).
If you've ever found profiling and optimization intimidating or slow with other tools, then JustTrace might be worth a look.
Don't forget nProf - a prefectly good, freeware profiler.
I have found dotTrace Profiler by JetBrains to be an excellent profiling tool for .NET and their ASP.NET mode is quality.
ANTS Profiler. I haven't used many, but I don't really have any complaints about ANTS. The visualization is really helpful.
AutomatedQA AQTime for timing and SciTech MemProfiler for memory.
If you're looking for something quick, easy, and free, http://code.google.com/p/slimtune/ seems to do the job fine.
I've been working with JetBrains dotTrace for WinForms and Console Apps (not tested on ASP.net yet), and it works quite well:
They recently also added a "Personal License" that is significantly cheaper than the corporate one. Still, if anyone else knows some cheaper or even free ones, I'd like to hear as well :-)
Don't forget the awesome scitech .net memory profiler
It's great for tracking down why your .net app is running out of memory.
I would add that dotTrace's ability to diff memory and performance trace sessions is absolutely invaluable (ANTS may also have a memory diff feature, but I didn't see a performance diff).
Being able to run a profiling session before and after a bug fix or enhancement, then compare the results is incredibly valuable, especially with a mammoth legacy .NET application (as in my case) where performance was never a priority and where finding bottlenecks could be VERY tedious. Doing a before-and-after diff allows you to see the change in call count for each method and the change in duration for each method.
This is helpful not only during code changes, but also if you have an application that uses a different database, say, for each client/customer. If one customer complains of slowness, you can run a profiling session using their database and compare the results with a "fast" database to determine which operations are contributing to the slowness. Of course there are many database-side performance tools, but sometimes I really helps to see the performance metrics from the application side (since that's closer to what the user's actually seeing).
Bottom line: dotTrace works great, and the diff is invaluable.
AQTime is reasonable, but has a bit of a learning curve and isn't as easy to use as the built in one in Team Suite
In the past, I’ve used the profiler that ships with Visual Studio Team System.
The current release of SharpDevelop (3.1.1) has a nice integrated profiler. It's quite fast, and integrates very well into the SharpDevelop IDE and its NUnit runner. Results are displayed in a flexible Tree/List style (use LINQ to create your own selection). Doubleclicking the displayed method jumps directly into the source code.
I've worked with RedGate's profiler in the past. Did the job for me.
Haven't tried it myself, but maybe dotTrace? Their ReSharper application is certainly a good one. Maybe dotTrace is too :)
I doubt that the profiler which comes with Visual Studio Team System is the best profiler, but I have found it to be good enough on many occasions. What specifically do you need beyond what VS offers?
EDIT: Unfortunately it is only available in VS Team System, but if you have access to that it is worth checking out.
The latest version of ANTS memory profiler (I think it's 5) simply rocks!!! I was haunting a leak using WinDbg and SOS since it proved to be the best way before, then I tried ANTS and I got it in minutes. Really a wonderful piece of software.
I would like to add yourkit java and .net profiler, I love it for Java, haven't tried .NET version though.
Unfortunate most of the profilers I tried failed when used with tail calls, most notably ANTS. I just end up writing my own. There is a simple implementation on CodeProject that you can use as a base.
Intel® VTune™ Performance Analyzer for quick sampling
I must bring an amazing tool to your notice which i have used sometime back. AVICode Interceptor Studio. In my previous company we used this wonderful tool to profile the webapplication (This is supposed to be the single largest web application in the world and the largest civilian IT project ever done). The performance team did wonders with the help of this magnificent tool. It is a pain to configure it, but that is a one time activity and i would say it is worth the time. Checkout this page for details.
Thanks,
James
For me SpeedTrace is the best tool on the market because it does not only help you to find bottlenecks inside your applications. It also helps you in troubleshooting scenarios to find out why your application was crashing, your setup did not install, your application hung up, your application performance is sometimes poor depending on the data input, e.g. to identify slow db transactions.
I've been testing Telerik's JustTrace recently and although it is well away from a finished product the guys are going in the right direction.
If Licensing is an issue you could try WINDBG for memory profiling
The NuMega True Time profiler lives on in DevPartner Studio by Micro Focus. It provides line and method level detail for .NET apps requiring only PDBs, no source needed (but it helps.) It can discriminate between algorithmically heavy routines versus those with long I/O waits using our proprietary per thread kernel mode timing driver. Version 10.5 ships with new 64-process support on February 4, 2011. Shameless plug: I work on the DevPartner product line. Follow up at http://www.DevPartner.com for news of the 10.5 launch.
Disclaimer: I am the Product Manager for DevPartner at Micro Focus.
I've found plenty of problems in a big C# app using this.
Usually the problem occurs during startup or shutdown as plugins are being loaded, and big data structures are being created, destroyed, serialized, or deserialized. Often they are created and initialized more than once, and change handlers get added multiple times, further compounding the problem.
In cases like this, the program can be so sluggish that only 2 samples are sufficient to pinpoint the guilty method / function / property call sites.
We selected YourKit Profiler for .NET in my company as it was the best value (price vs. feature). For a small company that wants to have flexible licensing (floating licenses) it was a perfect choice - ANTS was developer seat locket at the time.
Also, it provided us with the ability to attach to the running process which was not possible with dotTrace. Beware though that attaching is not the best option as everything .NET will slow down, but this was the only way to profile .NET applications started by other processes.
Feature wise, ANTS and dotTrace were better - but in the end YourKit was good enough.
If you're on ASP.NET MVC, you can try MVCMiniProfiler (http://benjii.me/2011/07/using-the-mvc-mini-profiler-with-entity-framework/)