Unit Tests as a Performance Benchmark. And Then What?

12 באוקטובר 2009

תגיות: , ,
אין תגובות

I’ve noticed a pattern with me – often, when I need to do some performance optimizations – I start off by using my “create unit test” Resharper template, writing the to-be-optimized code in a stopwatch block in it, and using TestDriven.Net to run it a couple of time to see if the time measurements are consistent.

Then I’m off to optimizing, and checking the optimization helped, and having coffee, and re-optimizing and refactoring and whatnot. Life’s great.

Then I’m done.

But I have a perfectly good performance test all written, just orphaned of an assertion…


I don’t really have a suggestion here. I know that just adding an assert on the time it took it a bit problematic, because tests can run on an assortment of environments (hardware+software) and in an assortment of scenarios (right after a boot or during Office2007SP2 install), so they might fail “randomly”.

I usually just comment out the code, feel bad about that, and a couple of months later delete it. Oh ,and feel bad about that, too.


So, readers, have you got any ideas?

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *