Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.




I was wondering if there is an easy way to remove all traces of SmartInspect from my source code.

I ask this, not because I’m planning to give SmartInspect the boot (I wouldn’t dream of that ;)), but because I’m working on a time critical app right now.

I’m wondering how much performance gain I might expect from removing the logging statements.


Hi Gerben,

If SmartInspect logging is disabled, you should normally not notice any differences when compared to removing the log statements (I just tested calling LogMessage 100.000.000 times with logging disabled and it took about one second only). Each SmartInspect log method checks if logging is enabled and if this if not the case, it exits immediately. What can cost some time though is evaluating method parameters, i.e. if you manually concatenate some strings and then pass them as arguments, for example.

We currently do not have a tool to automatically remove or insert log statements. But you should be able to do this with a more advanced Find and Replace tool (e.g. most log methods start with ‘Log’ or ‘Watch’). An alternative would be to surround log statements with conditional IFDEFs. This way you would be able to test the performance differences without the need to completely remove the log statements from your source code.

We have a performance and benchmark article in our article section called “SmartInspect Logging Performance and Benchmarks” which explains and compares the performance costs involved in logging. For performance critical applications, we normally recommend using the memory logging capabilities like the backlog functionality or the memory protocol and using mostly simple and therefore fast log methods (for example, LogMessage and WatchString are a lot faster than the more complex LogObject and LogDataSet).


Thought I’d offer this tip for Java users.

As you know Java doesn’t support conditional defines, so I use comments:

//[IFDEF:SMARTINSPECT]import SmartInspect


Note that the “[IFDEF:SMARTINSPECT]” is meaningless and you can use any string here, this just helps make it self explanatory.

And in an Ant build target I use a section like this:

    <copy todir="${debug-src-dir}">
        <fileset dir="${src-dir}">
            <include name="**/*.java"/>
        <filterset begintoken="//[IFDEF:" endtoken="]">
            <filter token="SMARTINSPECT" value=""/>

This copies all the source to a separate directory while stripping “//[IFDEF:SMARTINSPECT]” and leaving the remainder of the line. Then that directory gets compiled into a debug version of the application.

Doing it this way means we don’t have to ship SmartInspect.jar with the normal version of our app.

Hope this may help someone!