Using CodeSite to Spot Peformance Optimization Opportunities

I have been using CodeSite for a long time now (since v2 days), but I am still continually impressed by the product and it’s capabilities.  If you want to do something with your log data, chances are CodeSite has you covered, you just need to figure out how it is implemented.

Today, I wanted to see if I could filter on the TimeStamp column shown as a TimeDifference in order to only see log entries where the difference between one line and the next was over a second.  I figured this would show me potential opportunities for code optimization.  Initially I thought I would have to write some sort of log mining tool since there didn’t seem to be any capability to filter the log in this manner.  Developers often immediately jump to “I can solve this by writing some code”, but instead I asked my trusted friend Google.

Google showed me some release notes from a few versions back that documented a new feature in 4.62.  I hadn’t used this version so I had no idea the following was possible:

5. The CodeSite Viewers now support Time Difference Navigation. Specifically, a
   new mode has been added to the Message Navigation buttons (First, Previous,
   Next, and Last) to allow navigating to a message where the amount of time
   that has passed since the previously logged message exceeds some threshold.
   This new navigation mode is extremely helpful is locating time gaps in a
   message log.

   To use Time Difference Navigation, simply click on the "Browse for ..."
   drop-down button located between the Previous and Next navigation buttons.
   At the end of the popup menu, a new Time Difference menu item is available.
   Clicking the Time Difference menu item results in a dialog box asking for a
   threshold value (in milliseconds). Clicking OK closes the dialog box and
   puts the Viewer into Time Difference Navigation mode.  You can then use the
   First, Previous, Next, and Last navigation buttons to locate messages where
   the Time Difference of that message exceeds the specified threshold.

   To toggle back into normal Message Navigation mode, simply select the Time
   Difference menu item again from the drop down list of message types. The
   previous Message Navigation settings will be restored.

This is a sweet suite feature….thanks Ray!

7 Responses to “Using CodeSite to Spot Peformance Optimization Opportunities”

  1. Stefan Glienke Says:

    Using a logging tool to spot performance bottlenecks actually is not the best choice or are you going to instrument every single method in your code with Enter and Exit method calls?
    Better use a profiler like SamplingProfiler by Eric Grange or some commercial one like AQTime or NQS.

  2. Larry Hengen Says:


    Yes, AQTime is a better tool than using CodeSite for optimization. I use it, and find it very powerful, but not everyone can justify the cost of a license. CodeSite is a little more economical, and if you are logging things like SQL execution, it can help spot optimization opportunities. Logging provides a different view into the code. CodeSite tools can also be used to temporarily instrument method calls or code sections much as you would setup a profiler.

    I have not tried Eric’s sampling profiler since we have AQTime, but I will make a note to do so before we renew the AQTime license ;-)

  3. Bruce McGee Says:


    “or are you going to instrument every single method in your code with Enter and Exit method calls?”

    One of my favourite CodeSite features does exactly this, at least on a unit by unit basis.

    I agree that profiling is best done by a dedicated profiler, but I use CodeSite for ad-hoc performance monitoring all the time. Even so, I didn’t notice this feature. Thanks, Larry.

  4. Joseph Says:

    >…but not everyone can justify the cost of a license.

    That’s a problem with Delphi… profiling isn’t something optional for enterprise software development (neither is logging). A decent profiler should be included with Delphi (the bundled crippleware doesn’t work with 64 bit) and a logging unit should be part of the standard library. The cost of AQTime + CodeSite is $1000 USD, 2/3 of Delphi Pro’s cost! Other products today bundle profilers, logging, unit testing, code coverage and documentation generation into the standard library or IDE.

  5. Alexandre Machado Says:

    IMO, if you really want accurate profiling information, use a instrumenting profiler. A sample profiler just don’t cut it.
    There is a free open source profiler for Delphi that I’ve used many times and it worked very well.
    Deniele Teti explained how to use it here:
    It would be great to see such tool improved. Unfortunately I don’t have much time left :-(

  6. Larry Hengen Says:


    I agree with your comments which is why I have advocated repeatedly for EMBT to partner with open source initiatives to improve the product by “filling in the gaps”. There are tools out there to provide some of these items, but how many developers know they exist? If they were bundled with the product, and EMBT help improve and integrate them everyone would win!

  7. Larry Hengen Says:


    I finally got some time to look at Eric’s sampling profiler and under Basic Operations is says “Note that in this version of SamplingProfiler, sampling information is collected only for the application’s main thread.”.

    This restriction makes it unsuitable as an AQTime replacement for 99% of my projects.

Leave a Reply