¿Es posible perfilar parte de un método con Eqatec Profiler a través de su API?

I'm using Equatec profiler to diagnose a slow process of my application. I figured out which method is slow, but I want to know specifically which part of the method is slow. Aside from breaking up the method into multiple methods is there a way through the Eqatec Profiler API to mark specific sections of a method to be profiled separately from the entire method?

preguntado el 09 de marzo de 12 a las 23:03

2 Respuestas

Equatec is a good profiler, but in my experience here's what happens in a good-size .net app.

You may find a routine that's active a good percent of the time, like 20%, and you might even find a particular "hot" line inside it, but you can look at it and not really know what to do about it, because as far as you can tell, it's necessary.

At the same time, there could be something bigger than that lurking in the code that doesn't really show up very well in the profiler, because it's not confined to one routine.

If I can just give one example, I've seen an app that spends roughly 50% of it's startup time 20-30 levels deep in the call stack getting strings from resources just so it can display them to the user to let them know what's taking so long. If it found another way to do that it would start up twice as fast! The ANTS profiler (another good one) gave ninguna pista as to what was happening.

How did I find it? The old-time method, same way it's done here, y es se explica aquí.

The following graph shows, if you manually sample the stack N times, by pausing the program, and on Dos of those samples you see it doing something you could replace with something much faster, the amount of time you can expect to save, and the corresponding speedup ratio.

For example, the red curve (2/5) means if you take five stack samples, and you see what you could improve on two of them, you don't know precisely how much you will save. However, the most likely value is 2/5(40%, speedup 67%), the average is 3/7(43%, speedup 75%), and it would be somewhere in the range roughly between 10% (speedup 11%) and 70% (speedup 3.33x). That's in case you're thinking you can't trust small numbers of samples. Not a bad gamble. If you want more certainty, take more samples.

Beta distribution of cost for seeing something on S samples out of N total samples.

(Plot of Distribución beta X ~ Be( number of hits + 1, number of misses + 1 ) and Speedup = 1/(1-X).)

contestado el 23 de mayo de 17 a las 13:05

Your "startup time 20-30 levels deep"-example would be detected by the EQATEC Profiler: it always shows you the culprit, ie the method taking most time in total, and is not tricked by the fact that the expensive method was called from many other methods. That's a pretty powerful feature, in my humble opinion. - Richard Flamsholt

@Richard: If you remember, I was not able to run EQATEC on it, but I was able to run ANTS. Maybe ANTS is only a shadow of EQATEC, I don't know, but it works on the same principle of measuring method percents. That's the problem. There are lots of methods, call tree or not, with high percents. You look at them and they all look perfectly good. It isn't until you put aside measurement and instead examine a number of deep samples in time and ask "el porqué is this moment being spent?" that the problem appears. Measurements don't give reasons, and the problem doesn't appear without them. - mike dunlavey

I think ANTS is a fine profiler, but it can apparently get tricked by your example. Instead of thinking solely in call-trees and percentages the EQATEC profiler instead looks at the total for each and every method, so those taking up most time will "bubble up" to the top of the list of suspects. (BTW your problem back then was caused by signed assemblies - if you re-sign or skip these then it should work) - Richard Flamsholt

@Richard: Sorry I haven't had a chance to pursue that yet. It's lonely, but I'm suggesting an alternate paradigm: if one only looks for methods (or even lines of code) taking the most time, some things to fix to get speedup will be totally missed. I keep wondering if I'm wrong, but it's true. By measuring time of routines, you will see some things and miss others. Then the ones that are missed are the ones that become dominant as others are removed. To find them one needs to examine moments in time, not measurements. Try it & see. - mike dunlavey

Okay, so let's say 90% of startup time is spent in 10 methods, eg localization or string-operations etc. The profiler will show you this right away (sin tener en cuenta of their call-tree or "levels deep"!) and you can ideally optimize them to nothing. It's true that some other methods will then become dominant, but I honestly fail to see why you think they would remain "missed": with the 10 methods optimized away the new dominant ones would simply be at the top of the list now, ready for you to take on and investigate and optimize. - Richard Flamsholt

As of the current version 3.8.14: No, that's not possible. It would be a wonderful refinement, but it's not on EQATEC's immediate roadmap.

respondido 19 mar '12, 00:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.