ColdFusion and .NET: Comparing the Performance of Image Resizing

I received a comment from a reader named Daniel yesterday asking if I knew the performance difference in ColdFusion and .NET when resizing an image.  I did not know the answer, so I decided to spend a few minutes and run some tests.  I ran the code on the same server and used the exact same image to test the resize with.  Both pieces of code resized this image to 250 pixels.  The original width of the image was 660 pixels.  The ColdFusion code used a standard CFIMAGE call and the .NET code used the function I blogged out previously.  To test the time in milliseconds I used the GetTickCount function in ColdFusion and the Stopwatch class in .NET.  The timers were both started the line before the resize code and stopped the line after.  The performance difference was a little surprising.  The C# code perfomed much faster than the ColdFusion code.  Granted we are talking about milliseconds here, but even with that said the gap was quite large.  I ran each piece of code five times and took the average across those 5 requests:

ColdFusion: 453 milliseconds
.NET (C#): 66 milliseconds

I was very surprised at these results.  I then was curious to how things would look if I passed in a very large image.  I chose an image with an original width of 1680 pixels and resized it down to 250 pixels.  Those test results are:

ColdFusion: 1891 milliseconds
.NET (C#): 150 milliseconds

So using a different image the performance difference was still quite a large gap. 

I am curious now if I save out the C# code into a class and call it via ColdFusion, if that code would perform faster than using CFIMAGE.  Maybe another blog entry can try that out soon.

Comments

comments powered by Disqus