CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Aaron Jensen


Mock Framework Benchmarks

UPDATE: I tracked down the issue and committed a patch to Rhino.Mocks. Rhino.Mocks is now much more competetive performance wise, our CI build time nearly halved, and about 4 minutes out of 7 of our test time has disappeared. New numbers below.

I've complained before that Mocking is Slow but I never really dove further into it. Today I decided to actually compare Rhino.Mocks to other mock frameworks on a pure performance basis to see if it was a global problem. I timed 2000 unit tests across 100 classes with 20 tests each. The results were a bit surprising:

Framework TD.NET Time nunit-console Time
Rhino.Mocks old trunk 57.36s 28.82s
Rhino.Mocks new trunk 22.94s 7.59s
Moq trunk 18.30s 5.91s
TypeMock 4.2.3 Reflective Mocks 15.36s 9.35s
TypeMock 4.2.3 Natural Mocks 16.92s 9.56s

That's right, according to these tests, Rhino.Mocks is at least 3 times slower than the other frameworks when under heavy load in TD.NET and five times slower in the console according to these tests. It's also interesting to note that TypeMock is faster than Moq in TD.NET, but slower in the console runner.

While running the Rhino.Mocks tests it is very clear that there is a degrading performance issue. All the other frameworks executed tests with a near constant speed per test, but Rhino.Mocks slowed down noticeably about half way through.

Please feel free to try it yourself, grab the project here. You should be able to just run the 4 strategy .bat files (run-rhino, run-moq, run-tmock-reflective, run-tmock-natural). Let me know if you find anything interesting.



Comments

Colin Jack said:

Does this contribute to the 2 articles you have to write about liking TypeMock for the free license? :)

# May 8, 2008 1:26 PM

Lex Y. Li said:

What about NMock 2? Did you test on that?

# May 8, 2008 10:24 PM

aaronjensen said:

I don't really consider NMock2 a framework worth considering, as it lacks a strongly typed, refactor friendly syntax, so no, I didn't. Feel free to add a Strategy though and give it a shot.

# May 9, 2008 12:25 AM

Aaron Jensen said:

Just wanted to quickly note that I tracked down the performance issue in Rhino.Mocks and patched it

# May 9, 2008 1:56 AM

Community Blogs said:

Just wanted to quickly note that I tracked down the performance issue in Rhino.Mocks and patched it

# May 9, 2008 2:29 AM

Reflective Perspective - Chris Alcock » The Morning Brew #90 said:

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #90

# May 9, 2008 3:04 AM

Dew Drop - May 9, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - May 9, 2008 | Alvin Ashcraft's Morning Dew

# May 9, 2008 8:47 AM

Code Monkey Labs said:

Understanding Model-View-Controller : Introducing developers to the MVC concept can, at times, be a challenging endeavor. Jeff Atwood has put together a very informative post that may be able to help! Mocking Frameworks Benchmarked : In search of a faster

# May 9, 2008 10:57 AM

james.kovacs said:

I was equally confused when looking at a performance trace of Moq vs. Rhino. (I don't have TypeMock installed.) The majority of the time in both Moq and Rhino was spent creating proxies and both frameworks are using DynamicProxy2 for proxy creation. Something was definitely up. Excellent work tracking down the problem!

# May 10, 2008 2:09 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!