Hello, I'm building a new n-tier web application and I would like to know the performance differences between developing my tiers in one single assembly (each tier with its own namespace) or into different assemblies, one for each tier. Thanks.
+2
A:
Any differences are likely to be negligible. Loading classes will be a hair slower but not by much. (As part of the security model of the CLR, checks are done when execution crosses assembly boundaries.) If it makes sense to develop separate assemblies, do so. You can always refactor and/or recompile into a single assembly in the off chance that you have any performance issues. It's an interesting question, but nothing to worry about upfront for most development scenarios.
Larsenal
2010-08-02 18:23:32
from what i know instantiating a class takes something like 0,000009 sec or something like that, such small times makes it negligible so why would it be a performance hit?
Joakim
2010-08-02 18:51:49
As I understand it, security checks are done across assembly boundaries. So there is *some* non-zero performance hit. Like you say, it's going to be very, very small; but it would be incorrect to say there is absolutely no performance impact.
Larsenal
2010-08-02 18:55:41
Thank you all for your answer. I usually develop different tires into different assemblies just because it makes the architecture more clean and flexible. But I think it must have some performance hit, and I asked myself if it worth for a small web app. Thanks again.
opaera
2010-08-02 19:08:10
For a small app then who cares about that minimal performance issue. I would structure it for whatever makes it easier to develop and deploy. I prefer multiple assemblies as a change in one tier can be deployed by dropping a single DLL.
Dustin Laine
2010-08-02 19:18:13
Just because it is small... why develop different assemblies? I could develop one assembly and gain some performance. My question was due to the fact that I don't know the performance differences. Thanks anyway. (Sorry for my english).
opaera
2010-08-02 19:25:04
The performance difference is going to be really, really small. To put it in perspective, if you have one stray call to your database that will vastly outweigh the performance gain from compiling to a single assembly. There are far better places to optimize your code. This is certainly not the first place you'd start if you had performance problems.
Larsenal
2010-08-02 19:28:49
Thank you Larsenal, I'll finally develop my tiers into different assemblies as I always did, now I'm sure about that.By the way, I'm curious if someone had done some performace statistics around this one.Thanks again.
opaera
2010-08-02 19:33:11