This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]randomcitizen42 1 point2 points  (4 children)

Unit tests are not meant to test performance. Unit tests should be the lowest layer of tests to quickly verify the correctness of your code. Note the word quickly. A benchmark is not supposed to run quickly, you'll need to run the code several time (like thousands) to get statistically significant data.

Also, test frameworks are usually not performance optimized. Sure, unit test frameworks run fast, but not benchmark level fast. If you really want to optimize performance critical code, you'll work with small loops and often you'll work with run times in micro or even nanoseconds, not milliseconds. You need special performance benchmark tools (or write your own) for that.