Sometimes defects make your program go faster. Who needs all that extra input anyway, the user won't miss it. I believe some humans practice this productivity technique as well.
Stacks and Queues are interchangeable AS LONG AS you only ever have one item in them at a time. After that the difference becomes a little more pronounced.
Tuesday, September 16, 2008
Sunday, September 14, 2008
Pre-Optimization
I'm sure you've heard the saying "Pre-optimization is the root of all evil", or something similar. Well I have too, and I knew it before writing the serializer. But sometimes I can't help myself, I just know that doing it one way is going to be faster that some other way, or so I thought. The TokenStream class splits up the input stream into tokens. When I built the class I decided to only read from the physical reader if necessary when a token was requested by the parser. I'd gotten used to seeing that the Parser and Token stream classes took up most of the time spent during Deserialization when running them under the profiler. I figured it was just I/O taking so long and that I couldn't do anything about it. Well I finally decided to try something a little different, so I made a quick change to read all the tokens up front and store them. Wow! What a difference! That one little change made it about 4 times faster. It went from about an average of 20ms down to 5ms. That may be nitpicky since we're down here in the low millisecond range, but those numbers put us a lot closer to the Binary and Xml Serializers which I usually compare against. So it just goes to show that you should always profile and measure your optimizations to see if you're really improving anything.
Subscribe to:
Posts (Atom)