Nice Surprise
I'm doing some experiments to find out what happens if I put one layer of abstraction into some performance-critical code. I was fully expecting to have to write it in "the obvious way" and then to have to bust my butt optimizing it.
In my first experiment, I wrote three tests. The first performed a common operation using existing legacy code. The second performed the same operation with no abstraction, but with an implementation written by me meant to be production quality. The third was a rewrite of the second using one level of abstraction.
The second chunk of code is not strictly necessary, but it keeps the playing field completely level. Since I didn't write the legacy code, what it does is lets me compare what I consider production quality performance with what the legacy code considers production quality. This test is really just a litmus test for whether or not what I consider production code is equivalent to existing technology. That way, I also know that a comparison of the abstracted code to production quality is a valid comparison. In short, it means that if test two compares correctly to test one, then it's valid to compare test three to test one.
Enough on methodology. Surprising enough, the code with the abstraction is 1.5% slower than the non-abstracted code. I can't tell you how happy I am about this. I expected slower, but in the order of 10-20%. That means that my design should work nicely.
I'm pleased, but this is the first step. I'll be writing several other test cases to make sure my assumptions are valid.