Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can redundant "using"s degrade performance

Tags:

c#

reference

Just a performance question ...

Let's say I have 5 classes and each of them have a reference to System.Data and a homegrown Library. The 5 classes in question are a part of a Class Library and will eventually be built and published up to some web applications as a reference.

Is there any size/performance gained by taking the functions that reference System.Data and the other Library to their own class so that the number of times System.Data and my other Library gets referenced is reduced from 5 to 1? Common Sense is telling me that it doesn't matter because the DLLs would get read at the point of one of those functions being executed so it wouldn't matter where they sit or how many times you have "using System.Data" in your codebase ... but I've been wrong before :)

like image 214
cavillac Avatar asked Nov 15 '11 15:11

cavillac


People also ask

How does redundancy effect availability and reliability of a system?

Redundancy is a common approach to improve the reliability and availability of a system. Adding redundancy increases the cost and complexity of a system design and with the high reliability of modern electrical and mechanical components, many applications do not need redundancy in order to be successful.

What is redundant sub system?

Redundant System means the System or Software used in a non-production environment such as development, training, testing, or on a mirrored server for purposes of back up, archive, and disaster recovery purposes.

What are two differences between standby redundancy and active redundancy?

Standby redundancy: involves extra units that are not brought into use until the failure of the main unit is sensed. Load sharing: active redundancy where the failure of one unit places a greater stress on the remaining units.


1 Answers

No - using directives don't add references to assemblies; they import namespaces for code in the same scope. All they're doing is allowing you to use

Foo foo = new Foo(); // etc

in your code instead of

Some.Namespace.Containing.Foo foo = new Some.Namespace.Containing.Foo();

They don't change which assemblies are being referenced at all. It's important to understand the different between namespaces and assemblies - unfortunately as they often use the same names, it can be confusing. As an example of where they're different, the Enumerable class in the System.Linq namespace is in the System.Core assembly.

like image 182
Jon Skeet Avatar answered Sep 30 '22 03:09

Jon Skeet