Reputation: 1428
Here is the scenario. I have built a data wrapper class for executing stored procedures. I would like to use this class in other projects. As we all know it is usually imperative that data layer code should execute as quickly as possible to avoid bottle-necking.
So my question is, If I were to build my data class in its own assembly which is easier to distribute to other solutions, does this create any sort of load time penalty for the class itself? The other alternative is to copy and paste the class files into each project.
Upvotes: 0
Views: 122
Reputation: 7332
Types are loaded by the JIT the first moment you require some type from another assembly. It first loads the assembly itself then all types contained.
After that the types are in memory and there is no penalty in constructing them.
All this is true per AppDomain. But you are probably using only one.
So the performance issue you are referring to can happen only once pet assembly load.
If you are concerned this could be triggered when it should not, you can opt for preloading all the assemblies you need in advance (link to one question of mine).
Upvotes: 0
Reputation: 48596
You should note that while there is a non-zero (though likely trivial) cost associated with loading your assembly, in almost all cases it occurs only once per AppDomain, so bottle-necking is not a concern.
Upvotes: 2
Reputation: 29668
You realise, the entire framework falls into the category other
assemblies as well.
I don't think the timescales involved here matter and will impact on your processes.
Upvotes: 1