views:

55

answers:

1

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
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
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
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
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
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
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
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