Daniel Hoelbling-Inzko talks about programming

Don’t forget to turn of the debugger when doing performance testing

Recently our dotless lead tester Gert discovered a little bug in the dotless minifier that made the minifier “loose” css expressions that where not followed by a semicolon.

The fix to this was in theory quite simple, simply treat all closing braces } as semicolons so expressions are still terminated. Doing so then led to one new cause for problems: ; }.

Semicolons followed by a closing brace call the ExpressionBuilder with a empty value, the ExpressionBuilder can now either throw an exception or return null. I decided to try throwing exceptions first.

Returning null somehow felt less elegant and I did not consider the performance impact of throwing an exception. So after implementing I decided to test this and wrote a little benchmark console program to test my theories.

In Shock I watched the exception case to be 10 times slower than simply doing a null check. Hastily I reverted the exception check and started implementing the null-check in the dotless code when I remembered the debugger.

Doh! How could I run a performance test with the debugger attached. Ran the program without the debugger: exceptions where only twice as slow as the null check. Not too bad, but still not fast enough for dotless.

So, here some wisdom: Always make sure you run without the debugger when testing performance. Exceptions while debugging are roughly 10 times more expensive than without debugger.

Filed under net, programmierung

Thanks Lijit!

You may have seen that I use Lijit to power the on-site search for my blog. Since Lijit by default uses a Google custom search to power this (nothing really wrong with that) I became quite unhappy with the results (Google for some reason doesn’t like to index articles but rather indexes categories :(). Since I didn’t find my own stuff through Google, getting the same bad results through Lijit was quite annoying.

So I tweeted this one day:


Well, took about 45 minutes to receive this:


And this very nice Email alongside:


Well, that was 2 days ago. Search results that I get when using the on-site search are back to what I expect them to be and I’m once again able to find my own stuff.

Thanks Lijit. Great service!

Filed under personal, site-news

Removing .svn folders with Powershell

I needed one simple thing: Delete all .svn folders from a repository so I can send it to my customer. While searching most of the results I got where either wrong, or completely besides the point, so I decided it may be worth sharing:

get-childitem -Include .svn -Recurse -force | Remove-Item -Force –Recurse

Filed under programmierung, tools

Pandora used in dotless and moved to GitHub

Pandora, my personal IoC Container (mostly written for educational purposes) has recently been integrated into dotless. This has helped us improve the design of dotless without having to take on a big dependency like Windsor or StructureMap.

I chose to implement Pandora through the Common Service Locator interface by Microsoft, so if we ever feel restricted by Pandora we can easily switch to a more potent container without touching the actual dotless code.

This step also made me bring the Pandora repository from mercurial to git with some help from Horst. He was kind enough to run hg-fast-import for me.

Pandora can now be found on GitHub with a similar build process as dotless and elms-connector.

Pandora on GitHub

Writing ELMAH Exceptions to Log4Net

Yesterday a friend asked me if I know how to make ELMAH write exceptions to a Log4Net appender.
My first idea was to write a custom ErrorLog that would do that, but that’s not really possible since ELMAH must be able to retrieve errors after the fact so they can be displayed in ELMAH’s web interface.

Well, turns out it’s even simpler and more obvious by simply subclassing an existing ErrorLog and hook into the Log method:


Assuming you use the XmlFileErrorLog (you can use this method with all of them) you simply subclass it and put your call to Log4Net before the base.Log call:

public class Log4NetErrorLog : XmlFileErrorLog
    public Log4NetErrorLog(IDictionary config) : base(config)

    public Log4NetErrorLog(string logPath) : base(logPath)     {     }

    readonly ILog log = LogManager.GetLogger("bla");     public override string Log(Error error)     {         //Write whatever you want to Log4Net         log.Fatal("Exception logged through ELMAH: " + error.Message, error.Exception);         return base.Log(error);     } }

Now the only thing you have to do is change the errorLog line in your ELMAH configuration (found in web.config) to reference your new ErrorLog subclass:

    <errorLog type="MyAssembly.Log4NetErrorLog, MyAssembly" logPath="~/App_Data" />  

It will still log to XML, but also generate one entry per log to Log4Net. If you don’t want to save anything you can simply subclass the MemoryErrorLog class and set it’s size to 1.

Filed under net, programmierung

The joy of working with dotless

Ok, I just spent some time on the imagineClub website adding our board’s bio page. The HTML is not really interesting, but since imagineClub was written while dotless was still in development I wrote the CSS the old fashioned way.

Since dotless has reached some maturity I’ve been dogfooding it on imagineClub to make use of the minifier and the caching, but never had any real LESS code in there.
When I had to fix something today I was so happy to be able to write CSS like this:

    width: 414px;
        float: right;
        width: 300px;
        clear: right;
        font-size: @title-fontsize - 4;
        width: 100px;
        margin-bottom: 4px;

This is how CSS was supposed to be, and with dotless it has become just mindlessly easy to do..

ELMS-Connector documentation available

I decided not to invest any work in writing docs for a tool only I am using, due to the fact that it quite rapidly outdates during active development.

Well, ELMS-Connector development is mostly finished and after getting an email by someone from Amsterdam asking how to use ELMS-Connector I decided to finally write the docs.

The documentation is in the GitHub repository alongside the code, but I also saved it as PDF and uploaded it.

It’s by no means perfect, but it should be enough to get anyone who wants to use ELMS-Connector up and running quite smoothly. Comments are always welcome.

My Photography business


dynamic css for .NET