I’ve used ANTS in the past but had to write a little post about it because it is really neat. I’m a huge Reflector advocate. I have used it to create PowerGUI VSX and dig into the .NET framework. I wrote a blog post about all the cool stuff you can do with it in the past. When Red Gate bought Reflector, almost everyone and the mother was upset.
“It’s no longer free! Open source FTW! My son had to pay 15 dollars and now can’t come visit me! Rabble, rabble, rabble! ”
Well, I ran into an awesome integration Red Gate made with Reflector. It’s part of the ANTS profiler. This is really powerful. I’ll show you why.
Debugging using Reflector
There is a Reflector add-in that makes it possible to debug using it. I hadn’t had much success with it. You can also integrate Reflector into Visual Studio. This is actually really awesome. I had a lot of problems with the first incarnation but in the second version, Red Gate hit it out of the park. It just works. You can step right into decompiled code and see what is going on as it’s going on.
Profiling with Reflector
Now, Red Gate has upped the ante with ANTS. They have integrate the Reflector engine into their performance profile. This is really cool! I created a little test app that hosts PowerShell and runs the Start-Sleep cmdlet. It waits around for 30 seconds and then exits. Possibly the most useful script of all time.
I built the app in Visual Studio and profiled it using ANTS. The resulting data was actually really interesting. Once you switch over to wall-clock time, you can see a pretty interesting call tree.
The tree breaks down exactly what the PowerShell engine is doing (notice the cool DLRy stuff). This is super neat! Notice that it ends in the StartSleepCommad and finally in a WaitHandle to wait for the 30 second timeout I set. On the right you can see that the 30 seconds, did in fact elapse. The really cool thing is the pane underneath the call tree. It has a Decompile button! Give it a click and you can see exactly what the internals of PowerShell are doing. As you can see here, they are really just locking on a syncObject, which results in the WaitHandle call we saw in the call stack which causes the script to sleep for awhile.
The built in Visual Studio profiler is ok for most things but this ANTS profiler is wicked. I would love to hear about your experiences with it. Well this was a tangent…back to what I was originally doing…