Does anyone know about a profiler library in C# that I could embed in my source code that would do sample-based profiling? I.e. periodically get the instruction pointer location, store it in memory and allow to save it to a file and analyze later, presumably by some desktop application?
I know there are lots of traditional profiler applications (like JetBrains, Ants etc.), but I want to profile a C# program running on a non-desktop platform, where none of these profilers can be used. I want my application to sample itself, not an external profiler.
The Eqatec profiler might suit. I know at least in earlier versions the profiling got compiled into your binaries.
The user guide seems to provide a good overview of how to use it:
http://eqatec.zendesk.com/entries/20325613-user-guide#Intro
The ETW tracing infrastructure provides that capability. Try running the perfview tool by Microsoft. It uses ETW to show sampled stack traces.
You can use ETW yourself to build a sampling profiler. It might be a little work, though.
Related
I have a webservice that is in much need of some optimization. It's on an enterprise application the resides on a virtual server machine and is getting a huge bottle neck. I'm confident in my skills and being able to make this more efficient, but I was wondering if anyone out there has had a good experience with a profiler or optimization tool that would help point me to trouble spots.
The webservices main function is to generate PDFs which are created using Sql Reports and a third party PDF Writer utility. Basically it gets an ID and creates X number of PDFs based on number of Forms that are associated to that ID. So it has a loop which can run an average of 8 times / ID, and there are thousands of IDs sent daily. Needless to say there is always a back log of PDFs to be created, which the client would rather not see.
I have also thought about running multi-threads to asynchronously generate the PDF pages but I'm hesitant because they said they had issues with multi-threading on the "Virtual Server". So if anyone can point me to a good tutorial or advise about multi-threading on a Virtual Server I would appreciate that too.
Thanks for any help you can give.
I've used this one before and it's great:
JetBrains dotTrace
http://www.jetbrains.com/profiler/whatsnew/
Try Telerik's JustTrace, it has alot of neat stuff. It has 60 days free trial with support, so you can try it out first.
Fast Profiling
JustTrace aims to redefine fast memory and performance profiling. It adds minimal overhead to the profiled application, allows near seamless execution, and enables analysis-in-place, thus eliminating the need to move the application from its environment. The user can examine different stages of the application’s behavior by swiftly taking multiple snapshots throughout its lifetime.
Made-to-Measure Profiling
JustTrace offers three distinct profilers – Sampling, Memory and Tracing – to meet even the most demanding profiling requirements.
Profiling of Already Running Processes
JustTrace allows for unobtrusive attaching to live processes. Should an application start experiencing higher memory or CPU consumption, analysis on its state gives the opportunity to handle scenarios that are otherwise hard to reproduce.
Simple yet Intuitive UI
By definition, a memory and performance profiling tool should enable you to speed up the performance of your apps without slowing you down or getting into your way. JustTrace employs a minimalistic yet highly intuitive user interface that allows for easy navigation of the performance and memory results. A few effortless steps take you from choosing the application being profiled to an in-depth analysis of the profiling insights made by JustTrace. Memory and performance profiling has never been easier.
Live Profiling
JustTrace enables real-time monitoring of the application’s execution. The close-up watching of the application’s behavior brings out potential performance bottlenecks to the surface, and provides reliable hints of the application’s stages that are worth investigating.
Stand-alone Tool and Seamless Visual Studio Integration
JustTrace offers seamless integration with Visual Studio and can also be used as a stand-alone tool. The integration of JustTrace into Visual Studio’s UI removes a burdensome step by cutting the time needed to jump between the development environment and the tool to test the resulting memory and CPU utilization improvements. Simply modify the code, then run it through the Visual Studio UI and get JustTrace’s core capabilities in a single tool window.
Profiling of Multiple Application Types
JustTrace enables the profiling of local applications, running applications, Silverlight applications and local ASP .NET web site.
I would suggest taking a look at ANTS Memory & Performance Profiler from Red Gate:
ANTS Memory Profiler
ANTS Performance Profiler
The ANTS profilers do a fantastic job of identifying bottlenecks and memory leaks. They're not free, but they're very affordable and offer fully functional trials so you can evaluate the products.
There are other profilers:
ANTS: http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
Which can also profile SQL calls. They also have an EAP open at the moment which gives you more functionality for database calls, that is here:
http://help.red-gate.com/help/ANTSPerformanceProfiler/download_eap.html
There is YourKit:
http://www.yourkit.com/
Visual Studio has a profiler too but not as good.
If I want to add some instrumentation in my code for getting metrics like how long a particular method took to execute, anyone has recommendation for either windows build-in or any 3rd party library?
I've seen this done with PostSharp AOP framework, hooked into Windows Performance Counters (System.Diagnostics.PerformanceCounter). One of their introductory pieces of sample code shows how to do this:
http://www.sharpcrafters.com/solutions/performance
This might be a good option if you want to deploy these measurements to production and measure performance in a live manner (to do diagnosis of a running system).
If you just want to locate bottlenecks in your code, and don't need to do live diagnosis, I suggest you simply use a profiler, such as the one built into VS or Ants Profiler (as Chris already suggested). Then run a redacted copy of your production data against your code so your performance measurements match production.
If you want this at runtime, you should probably use a profiler offline. I'd avoid doing any instrumentation where possible as it takes time and therefore causes more performance problems.
Google for RedGate ANTS Profiler or JetBrains dotTrace. If you have VS2010 Premium, it has one built in. That will give you a method-level breakdown of what is happening time-wise.
Generally a profiler will take care of measuring performance.
If you need to measure time yourself StopWatch with some sort of tracing is often enough.
We have an application which is developed in the C# .NET Framework 2.0 that is interacting with a COM component(which is developed in C++ unmanaged code). Sometimes the application throws an out of memory exception(quite hard to reproduce).
We would like to have a tool to find out if we have any memory leaks, and identify the root cause of the memory exception. What tools would be best for this? An ideal tool would be able to attach to a running process on a user's machine to do analysis.
We have tried .NET memory profiler but that can only attach to a .NET framework 4.0 running process. We also used Memory Validator (C++ memory leak detector); however, this tool didn't give us enough hints when attaching to a running process.
Use a memory profiler - they can help to find such leaks, for example:
http://memprofiler.com/ (commercial, managed PLUS unmanaged integrated in one profiler!)
http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/ (commercial)
CLR Profiler from MS (free)
Short answer
Have you tried Microsoft Application Verifier? It is a very small, I'd daresay minimalistic, but surprisingly powerful tool.
Long answer
During my investigation of the memory leak issues, I have used Microsoft Windbg, Microsoft Application Verifier and I have thoroughly evaluated Red Gate ANTS Performance Profiler (which I have recommend to buy, and I have personally seen recommended to buy by various developers in many different teams), DotTrace and .Net Memory Profiler.
There is definitively value to get and learn how to use one or more of such tools, perhaps then installed on a virtual development environment hosted on some virtual machine pooled between the developers of the team.
If you evaluate those and any other tool, the big selling point for me would be the ability to investigate memory dumps taken with Windbg, as those are the most easily obtainable even from customers.
try WinDbg and this receipt: http://www.codeproject.com/KB/cpp/MemoryLeak.aspx
For the most basic tests, you could use sysinternals procexp.exe to check if you really have a memory leak problem. A lot of COM code would throw out-of-memory, when a null pointer is encountered where one wasn't expected, so the exception code may be misleading.
We've build a Web Application which is performing horrible even with alot of resources available. My boss doesn't believe me that the application is consuming alot of Hardware IO, so I have to prove that the hardware is ok, but the web app is really crap.
The app is using:
SQL Server 2000 with SP4
The main web application (.NET 3.5)
Two Web Services (.NET 1.1)
Biztalk 2004
There are 30 people using this apps.
How can I prove I am right?
You can hook up a profiler like ANTS profiler or JetBrains DotTrace and see where the application's performance bottlenecks are.
One place you could start is getting a performance profiler like Red-Gate ANTS profiler. I've used this tool and it's very useful is weeding out performance bottlenecks.
Randy
You could start by using SQL Server Profiler to get an impression of the amount of database traffic that is going on.
I'm not saying that database interaction is the bottleneck, but it often is, and the tool is already there if you are using SQL Server, so it may be a good idea to take a look at that before you go out and buy a lot of profiling tools.
Visual Studio 2008 also have built-in performance analysis tools.
Windows performance counters are a good way to get some basic information about general system performance. Proper counters will show you if it's really the IO that's doing lots of stuff. If you take out the numbers from the counters and compare those to the specs, you should be able to tell if the system is maxing out or not.
If the system is maxing out, it's a problem with the web application, and it should be profiled to find out where to start optimizing.
You could use the system performance monitor built into windows since at least XP. You can get almost any information you could possibly need. This includes CPU time, .NET memory usage (include gen0 gen1 and gen2), native memory usage, amount of time spent garbage collection, disk access time, etc. If you just search codeproject or just the web there are many examples of using these counter to test for just about anything you want.
One of the benefits of this is you don't have to change your code and can be used with existing system.
I find this is the best starting point to point you to where you should look for bottle necks and issues.
I am developing a c# GUI and was wondering if there were any (preferably free) runtime diagnostic programs available.
What Im looking for is a way to monitor user interactions with my GUI and what functions are called when. Preferably I do not want to add stacks of debug code as this has the potential to change the behaviour of the bug I am looking for.
Currently Im using Spy++ but am finding it a little heavy going as Im kinda new to this and its generating stacks of data.
EQATEC profiler is pretty simple to use. Free too. Started life targetting Compact Framework but since 2.00 is now geared more towards Desktop too.
I recommend ANTS profiler.
There is a trial available, first two weeks free.
In addition to ANTS profiler have a look at JetBrain's dotTrace