views:

323

answers:

1

I've made a simple hello world project in asp.net mvc2,3 aspx and 3 razor and benchmarked them. What I see is:

asp.net mvc 2 aspx : 4200 request per second

asp.net mvc 3 aspx : 3200 request per second

asp.net mvc 3 razor : 1700 request per second

What's wrong with razor, it's so slow?

Update: I've redone the test. All 4 test virtual directories uses the same .net 4 integrated mode app pool. All projects are done with add new empty x project and adding 1 page with 1 line text and with no code. all sites are compiled in release mode. My system is windows 7, 4 gb i7 4 cores. I've run the test 2 times to warm up iis and these are second run results. apache bench parameters : ab -n100000 -c1000 results:

asp.net 4 - rps: 4780 cpu: %43

mcv 2 - rps: 4322 cpu: %58

mvc 3 beta 1 aspx - rps: 2324 cpu: %54

mvc 3 beta 1 razor - rps: 1615 cpu: %54

Update 2 Scott Guthrie answered in his blog:

We haven't fully optimized MVC3 yet (there is usually a lot of cache tuning we do). We expect razor to be the same performance as the .aspx view engine before it is finally released.

+7  A: 

How did you perform the benchmark? Was your site deployed on IIS in mode Release? Did you use the <deployment retail="true" /> section in your machine.config? Also remember that ASP.NET MVC 3 is still under heavy development so you cannot expect it to be fully optimized yet. At least wait until it hits RTM.

Darin Dimitrov
yes in release mode on iis 7.5. I've tested with ab (Apache benchmark) and run 50.000 requests with 500 - 1000 clients. I've tested it two times and these numbers are the second results (first ones are lower). I know it's under development but not sure 3x performance gain is possible after optimization.
sirmak
Why are you sure that 3x optimsation is not possible? The ASP.NET team have already stated that the Razor parser is not optimised yet.
MikeB
Beta 1 released and razor rps dropped to 1550.
sirmak
@sirmak we are aware of certain performance issues with the current Beta bits. Did you rerun your tests for all 3 configurations or just Razor on MVC 3 (if the machine is under a different load then runs might not be comparable). Is your test app really just a simple Hello World page? I find it surprising that the difference is so big between Razor and ASPX, considering that when you have a very simple page the time spent rendering is relatively small.
marcind
it was jus a simple hello world test and cpu usage was approx. %40 on a 4 core i7 for razor. I couldn't remember aspx cpu usages. I'm running all tests in the same conditions on a windows 7 and sample applications were same empty projects. I'll make a fresh new test for all and return to you with more detail.
sirmak
Hi, I've redone the test and updated my question.
sirmak