0

I know a similar question has already been asked here What features should a C#/.NET profiler have? but this thread is not only about the wishlist but also about how to go about implementing that wishlist.

So let me ask you this just once more. I am in the process of building a generic performance profiler. I know I can take in a dll as input and take the usual Stopwatch approach to profile the response times of methods in that dll. But this is very basic stuff. I am willing to use third party api(or do some code on my own too) to extract whatever useful information I can lay my hands on from that dll. I want to know everything that makes it slow. I want to know about it's memory leaks. Anything at all that would help me find bottlenecks of the application. I'd want similar approach to find expensive db operations. But all this, under one application.

So what approach do you suggest? Which tools can I bring under my umbrella so that I can use them in my project?

I want to make a 'single' application that will take generic inputs like dlls, can also take input as source code tree(solution, projects, .cs files) and emit out results in the form of response times, identifying bottlenecks, memory leaks, etc.

Community
  • 1
  • 1
Kumar Vaibhav
  • 2,632
  • 8
  • 32
  • 54
  • You're looking for the .Net profiling API. – SLaks May 15 '12 at 20:38
  • in the *general* case (especially taking dlls as input and outputs), this is a problem of significant complexity; make sure you aren't under-estimating what might be involved here! One could almost say (although not quite, obviously): "if you can't already answer this question yourself, your chances of writing an effective profiler are slim to none" – Marc Gravell May 15 '12 at 21:08
  • @MarcGravell - So how should one go about taking input from the other projects? I am just in planning phase right now. – Kumar Vaibhav May 16 '12 at 06:38
  • define "taking input from the other projects" – Marc Gravell May 16 '12 at 06:49
  • @MarcGravell - Well I will have access to source codes of projects since they are all products of our own firm. Now what should my input be? If I take dlls as input and try out reflecting upon them and then go about analyzing them, then it'd be very slow. – Kumar Vaibhav May 16 '12 at 08:35
  • @Kumar you are asking a question that is much larger and much more complex than you seem to realise. But as a starter for 10: the CLI debugging and instrumentation APIs, probably from C++ – Marc Gravell May 16 '12 at 08:45
  • @MarcGravell - Yes that's why I am looking at the .Net profiling API and also trying to integrate mvc mini profiler in some ways. – Kumar Vaibhav May 16 '12 at 12:30

1 Answers1

1

Anything at all that would help me find bottlenecks of the application.

Be careful of the universal profiling assumption that measurements unerringly lead to where the bottlenecks are, because some of them can be found that way, but only some.

Then the remaining bottlenecks sit there consuming time needlessly, but the developer is oblivious to them because profiler measurements did not isolate them.

A simple example could be some sort of dictionary lookup that appears to be optimal, except that the words being looked up are highly non-random. If certain words are looked up much more frequently, that represents an opportunity for optimization, but to detect that you need to know something about the data. Measuring profilers don't look at the program's data.

A more extreme example is any sort of interpreter, whose data is the "instruction set" for another language. The bottlenecks could easily be in that other language, but since it is data the measuring profiler would not see them.

What does see problems of this sort are not measurements but a small number of samples of the program's state, where the developer can fully examine and characterize the content of each sample (call stack and data). This leads to a much better understanding of how and why the program is spending its time than putting measurements on methods or browsing a call graph.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135