none
Does using statements or project references slow down application?

    Question

  • Hi!

     

    I am now polishing my first WP7 game and I just wondered whether using statements and project references slows loading speed or something?

     

    Thanks.

    Friday, July 15, 2011 12:55 PM

Answers

All replies

  • Hi

     

    I dont think using statements slows down the loading speed.

    Infact, you can take a look the usefulness of "USING" statement here..

    http://msdn.microsoft.com/en-us/library/yh598w02.aspx

    As per project references is concerned, it depends on the type of project you have referenced. whether its a .NET application or a COM component.


    Regards TurbulentGeek "
    Mark as answer if it helped you..."
    ;
    Friday, July 15, 2011 1:08 PM
  • Since each reference needs to be loaded it impacts startup time. Using statements are not impacting performance.

    Friday, July 15, 2011 1:10 PM
  • Unnecessary using statements and project references definitely decrease the performance,

    It check the reference every time when the page loaded.so it is necessary to remove the unwanted references and using statement in the page....

     

    You have to remove the unnecessary references for performance


    J.Arun Prakash http://royalarun.blogspot.com/ Marked as answer if it is useful
    Friday, July 15, 2011 1:26 PM
  • I believe Andreas is correct.  This is why tools like ReSharper actually have a remove unused Usings command.  But, VS2010 adds a ton of usings just for the convienience factor.  So a good refactoring tool is needed.
    JP
    Friday, July 15, 2011 1:27 PM
  • I agree with project references but not that using statement decrease performance. Using statements are only for us and the compiler and do not impact runtime performance. We can remove all using statements and write code like this instead:

    System.String str = "hello world";
    System.Collections.Generic.List<string> lst = new System.Collections.Generic.List<string>();

    You are talking about pages I guess you refer to ASP.NET? Pages get compiled and cached and not over and over again on every page load.

    It is good practice to remove using statements that are not needed, reduces clutter and makes source more readable.

     

    Friday, July 15, 2011 1:42 PM
  • Chapter 5 — Improving Managed Code Performance:
    No where in above MSDN link it specifies that Using  will reduce the performance... (this is different from IDisposable using which is used to increase performance)
    But as a part of practice, you can simply right click on the project, and click on "Remove and Sort Usings". This action will remove all unused Using references.

    -Jai
    Friday, July 15, 2011 1:52 PM
  • using statements do not impact performance at all. In a compiled assembly, it is impossible to tell whether using statements were used.

    References will slow down a program in the sense that the more of them you have, the slower the program will load. However, I have never had an issue with a program being slow because of references. You do not have to worry about unused references slowing your program down. Visual Studio handily eliminates any unused references.

    Friday, July 15, 2011 3:04 PM
  • Having lots of using statements might slow down the Visual Studio IDE while editing your code, as the intellisense window has to filter through many more types. The same applies to build times, the compiler has to check more namespaces in order to resolve a type, making your build slower than needed.

    As Visual Studio and Resharper do background compilation, it is important for the IDE performance to reduce the number of using statements to improve the responsiveness of the IDE. Though most of this processing happens on a background thread, so if you have a multicore machine (and who hasn't nowadays), the difference should not be that great.

    Once the compiler has compiled your code, the number of project references and the number of using statement don't matter anymore. What does matter are the actual used assemblies in your code. The compiler is smart enough not to add a load request to assemblies that were added to the project, but were never used in the code. Though the more assemblies you have in the GAC or in your applications folder, the longer type resolving will take. Once resolved, the difference is again negligibleas the result will be cache for the lifetime of your application.

    Remember that you can speed up your application by creating native images of your assemblies using ngen.

    Saturday, July 16, 2011 12:20 PM
  •   Using is very sensitive   will  Create Application Shutdown / Crash 
    MichaelUSA
    Saturday, July 16, 2011 9:17 PM