Jason Crease

Test Engineer - Red Gate Software

  • Testing the speed of ANTS Profiler 4

    Posted Tuesday, September 16, 2008 2:55 PM | 0 Comments

    Profiling and debugging code inevitably adds overhead, and I know that it can be really frustrating. The overhead can either be small, e.g. the Visual Studio debugger, or massive, as with most performance profilers. A developer may invest in a performance profiler to optimize an algorithm that takes 10 minutes to run, and finds that when profiled it takes 2 hours to run. A top priority in the development of ANTS Profiler 4 was to make it faster than its predecessor and faster than any other profiler on the market.

    We have found ANTS Profiler 4 to be about eight times faster than its predecessor, ANTS Profiler 3. It is also 4 to 20 times faster at line-level profiling than other profilers on the market.

    I did a few speed tests and I have made a video to show how ANTS Profiler 4 compares to the fastest-known other profiler:

    ANTS Profiler 4 vs fastest known competitor

    Here it is compared to ANTS Profiler 3:

    ANTS Profiler 4 vs ANTS Profiler 3

    If you want to try out ANTS Profiler 4, you can download it from the RedGate website
  • A Quick .NET Puzzle

    Posted Thursday, July 17, 2008 6:17 PM | 3 Comments

    Just a quick .NET puzzle.  Does this application ever throw that ApplicationException?  If so, why?


    using System;
    using System.Threading;

    class Program
    {
        
    static long Num = 0;

        
    static void Main(string[] args)
        
    {
            Thread t1
    = new Thread(ModifyNum);
            
    t1.Start();
            
    while (true)
            
    {
                
    long k = Num;
                
    if (k != -&& k != 0) throw new ApplicationException(
                    
    "k is not -1 or 0.  It is " + k.ToString());
            
    }
        }

        
    static void ModifyNum()
        
    {
            while
    (true)
            
    {
                
    if (Num == -1) Num = 0;
                
    else Num = -1;
            
    }
        }
    }

    Stuck?  Then here's a hint: if you change Num from a long to an int, it never throws the exception.

  • ANTS Performance Profiler 4 = Sexy Software!?

    Posted Tuesday, June 03, 2008 5:46 PM | 2 Comments

    I sit next to this guy called Stephen Chambers. He is the Usability Engineer working on our next version of our code profiler, ANTS Performance Profiler 4. He is completely revising the UI of ANTS Profiler, and spends most of his time phoning developers asking what they would like to see in the next version, and then designing the new UI based on the feedback he gets.

    Occasionally, you’ll hear some outbursts such as: “It’s getting hotter and hotter round heeere!” If you ask him what he’s on about, he’ll reply in an apologetic tone, “I can’t help it…. It really is very sexy!” That’s when I realise he’s talking about ANTS Performance Profiler 4 (APP 4) and the new design he’s working on. He’s contemplating the slick interface and clean lines of the profiler, summoning passers-by to come and check out “How god damn sexy it looks!”

    So, the other day I asked for more detail. What exactly makes Stephen so animated?

    1. One-click profiling

    He loves the one-click profiling concept. He spent a lot of time working on the opening dialog. No 52-step wizards - just a single screen. The opening dialog is implemented to allow immediate profiling. That way, users will be more inclined to use the tool a lot more frequently, because it’s so quick and easy.

    Figure 1: Opening Dialog of ANTS Performance Profiler 4

    2. Much greater control for the user

    The decision to remove the concept of ‘snapshots’ has produced an entirely new way of interacting with the profiler. Why confine the user to ‘snapshots’ when he could just choose any arbitrary period of time? Simply highlight any period of time (e.g. the creation of a Form), and see profiling results for that period.

    Figure 2: Timeline feature in ANTS Performance Profiler 4

    With snapshots, you must remember to switch back to the profiler to take a snapshot, reset results, etc. The need to switch from a task to the profiler has now been removed. The user can perform any number of actions they wish and retrospectively analyze the performance of each task in as much depth as they wish.

    3. Responsiveness of the interface

    Stephen has so far organised over 15 hours of testing sessions with users of the Early Access Program of APP 4. I asked him about their feedback. It seems that participants to the usability sessions have been stunned by the speed at which the results for a given region are processed and displayed. This can equally be done while the profiled application is running or after it has exited.

    4. Clear and simple interface

    Given the inherent complications of performance profiling, creating a front end that keeps things simple and immediate was a priority for Stephen. The UI went through several iterations and one of the main achievements of the APP 4 development team has been the reduction of options and windows on the main UI. Stephen seems to be getting a satisfying feeling watching a participant in a feedback session of APP 4 install it, set-up a project to be profiled and locate a performance bottleneck within minutes. The power of the profiler is as it should be – hidden under the surface with just the right number of options at the right time to give the user the power to examine the data in any way they feel like.

    5. Not throwing the baby out with the bathwater

    Talking to existing users of ANTS Profiler 3 revealed a huge amount about not only what features people would like to see in a new version but also what they really liked about the existing version. ANTS Profiler is well-known for its slick line-level timings feature, and some were concerned a new versions may present a ‘change for the worse’. APP 4 represents innovation in many areas, but preserves the features that people found genuinely useful in ANTS Profiler 3. We originally considered dropping the ‘All Methods Grid’, but this decision was quickly reversed upon talking to customers. Instead of a removal or total re-design, a number of subtle tweaks were made to simply freshen up its appearance and extend its usefulness. For example performance bars were added to heighten the visibility of poorly performing methods.

    Figure 3: The fresher ‘All Methods’ grid in ANTS Performance Profiler 4

    The code view has retained the iconic ANTS Profiler 3 red bars but we have tweaked its functionality by showing the currently selected method.

     

    I find Stephen’s passion for his work impressive. He gets amazing satisfaction from watching users understand the features and options available, and listening to users saying “oh wow, that’s what I call a responsive profiler!” or “very clean interface!” Admittedly, a lot of work went into these things, so I guess, I can understand that…but I can’t help feeling a little uneasy when I see Stephen dancing on his chair, singing “ANTS Performance Profiler, Sexy Software…”!

  • Order of Construction

    Posted Monday, June 02, 2008 4:05 PM | 3 Comments

     

    For me, inheritance is often a headache.  In particular, in what order is everything initialized?  Consider this short C# program.   It creates an instance of Dog, which derives from Animal.  Both Dog and Animal have an instance constructor, a class initializer (aka a static constructor), an instance variable, and a static variable. 

    using System;
    

    namespace CtorOrder
    {
        
    class Animal
        {
            
    public int instanceAnimal Program.Print("Animal.instanceAnimal");
            
    public static int staticAnimal Program.Print("Animal.staticAnimal");
            
    public Animal()
            
    {
                Console.WriteLine
    ("Animal constructor");
            
    }
            
    static Animal()
            
    {
                Console.WriteLine
    ("Animal class constructor");
            
    }
        }
        
    class Dog Animal
        {
            
    public int instanceDog Program.Print("Dog.instanceDog");
            
    public static int staticDog Program.Print("Dog.staticDog");
     
            
    public Dog()
            
    {
                Console.WriteLine
    ("Dog constructor");
            
    }
            
    static Dog()
            
    {
                Console.WriteLine
    ("Dog class constructor");
            
    }
        }
     
        
    class Program
        {
            
    public static int Print(string s)
            
    {
                Console.WriteLine
    (s);
                
    return 0;
            
    }
            
    static void Main(string[] args)
            
    {
                Dog d 
    = new Dog();
                
    Console.WriteLine("\nPress enter to continue");
                
    Console.ReadLine();
            
    }
        }
    }

    There are eight activities here:

    1. Dog instance constructor
    2. Dog class constructor
    3. Dog instance variable
    4. Dog static variable
    5. Animal instance constructor
    6. Animal class constructor
    7. Animal instance variable
    8. Animal static variable

    The question is: ‘In what order are the eight activities run?’  Try working it out.  Anyway, the answer is:

    1. Dog static variable
    2. Dog class constructor
    3. Dog instance variable
    4. Animal static variable
    5. Animal class constructor
    6. Animal instance variable
    7. Animal instance constructor
    8. Dog instance constructor

    There are two things I find surprising about this:

    1. Why do static constructors run from most derived class to least derived class, i.e. Dog then Animal?
    2. Why do instance variables get initialized before calling the parent’s instance constructor?

    The answer to question 1 is that Dog’s class initializer has to be run since we are running Dog’s instance constructor, but execution of any type's class initializer method will not trigger automatic execution of any class initializer methods defined by its base type.  Indeed, why should it?

     

    The answer to question 2 is complicated.  Constructing instance fields in the most derived class first is the only way to ensure that readonly fields are initialized and then not changed.  Check out Eric Lippert’s blog for a decent explanation: http://blogs.msdn.com/ericlippert/archive/2008/02/15/why-do-initializers-run-in-the-opposite-order-as-constructors-part-one.aspx

  • Using the Exception Hunter Command Line to find All Methods that throw a given Exception

    Posted Thursday, January 31, 2008 12:01 PM | (Comments Off)

    Red-Gate's new .NET tool - Exception Hunter - shows you the exceptions that can be thrown by a .NET method. However, many users would like to see this the other way round, i.e. pick an exception and see which methods throw that exception. We will endeavour to put this in the next version of Exception Hunter.

    However, for the moment this functionality is available via the Exception Hunter command line. I've recorded a 5-minute video where I demonstrate how to use the command-line to find all methods that throw IO exceptions in a simple application. Have a look...

    http://www.simple-talk.com/blogbits/jason_crease/Exception_Hunter_Command_Line_demo_skin.swf

    To download the 14-day free-trial of the .NET Developer Bundle, which includes Exception Hunter, go to:

    Download .NET Developer Bundle


















<October 2008>
SuMoTuWeThFrSa
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Using Powershell to Generate Table-Creation Scripts
 For all of us who learn best by trying out examples, Bob Sheldon produces a PowerShell script file for... Read more...

Configuring Exchange Server 2007 to Support Information Rights Management
 In Exchange Server 2007, Information Rights management is easy to set up once you have set up the... Read more...

SQL Response: The dim sum interview
 Richard Morris met David and Nigel of the SQL Response team, in a dim sum Restaurant in Cambridge. They... Read more...

Why This SQL Server DBA is Learning Powershell
 Ron describes how he decided to study Powershell as a single scripting system to automate all the... Read more...

Using Covering Indexes to Improve Query Performance
 Designers of database systems will often assume that the use of a clustered index is always the best... Read more...