Geeks With Blogs
Lou Vega a thump to the brain

This started out innocently enough - I was looking for a simple way to start experimenting with the Performance Wizard tool that's included with Visual Studio Team Edition for Developers so to keep things simple, my Performance Wizard "hello world!" became this little bit of code:

Imports System.text
Module PerfJunkie
    Private ReallyBigString As String
    Sub Concatenate(ByVal Junk As String)
        ReallyBigString = ReallyBigString & Junk
    End Sub
    Sub Main()
        For i As Int16 = 0 To (Int16.MaxValue - 1)
    End Sub
End Module

Well of course we can immediately see some areas where this little diddy can be optimized to perform better. For one, the use of a Stringbuilder versus String... in this case using String with concatenation accounts for nearly 80% of the processing time alone. But after that rather obvious improvement, I started to explore...and in the end I got the whole thing to dump out the results almost immediately after hitting F5 to run...a nice improvement over the original run time of over 11 seconds (granted I've working on a rather underpowered machine here, but them's the breaks I live with!)

So then - what other improvements can you see with this? I've already come to my own conclusion while working through and becoming familiar with the Performance Wizard tool (really a neat tool if you ask me!) but I'm curious to see what other minds are thinking.

Posted on Friday, December 29, 2006 10:00 PM Visual Studio Team System | Back to top

Comments on this post: Confessions of a performance junkie...Part I

# re: Confessions of a performance junkie...Part I
Requesting Gravatar...
A StringBuilder instantiated with a large buffer. That will do two things: reduce the number of reallocations and cause the buffer to be allocated on the large object heap which will prevent any performance hit from heap compaction.
Left by Anthony Trudeau on Dec 30, 2006 9:32 AM

# re: Confessions of a performance junkie...Part I
Requesting Gravatar...
I actually had a couple of guys do this at my last presentation and mentioned it cut execution time down by 2/10ths of a second :)

Left by Lou on Oct 30, 2007 8:39 AM

Your comment:
 (will show your gravatar)

Copyright © Lou Vega | Powered by: