Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Ray-Pendergraph · Jul 28, 2010 at 02:04 PM · performancenamespace

Performance implications of namespaces in Unity.

I would like to get some community feedback here. I see a lot of discussion out there about the performance differences between the logical and syntax aspects between C# and UnityScript. However, some of my colleagues and I are debating about the performance implications of using namespaces in the unity runtime. It has been asserted by someone that simply using namespaces causes degradation over the entire runtime and lowers frame rate. If I have missed an existing post somewhere covering this specifically could you please reference it?

Does the use of namespaces cause performance degradation? If so, when is this degradation realized in the lifecycle of the scene graph (Awake, continuous, etc)? Is it only while loading any imported assemblies or any time a MonoBehavior using a custom namespace is created (for example)?

Edit(6/29): Because of the responses here and some other discussions I have read on the web (of which there is a very good one here), I think this myth is BUSTED! The act of using namespaces does not impact runtime performance of code with the exception of using the reflection API. It's largely a compile time effort. The generated IL (using UnityScript or C#) has fully qualified classes anyway. Also, if this were true then the use of all UnityEngine and UnityEditor classes would be "degrading performance".

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Mike 3 · Jul 28, 2010 at 06:38 PM

If you're talking about using namespaces around your own code, then no - it's something which doesn't make any difference outside of compiling and using reflection

If you're talking about using namespaces at the top of files, it can add to the build size, and any of the code used from those namespaces could cause slowdowns - but that has nothing to do with the namespace itself

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Eric5h5 · Jul 28, 2010 at 07:21 PM

If you mean something like

import System;

function Start () { print (DateTime.Now); }

as opposed to

function Start () {
   print (System.DateTime.Now);
}

then those are the exact same thing. Importing a namespace doesn't "do" anything and can't affect performance in any possible way. If you have import System.Security.Cryptography in your script but don't actually use any functions from System.Security.Cryptography, then nothing will happen.

It just makes typing stuff more convenient. With C#, for example, having using UnityEngine in your script just means you can type Vector3 instead of UnityEngine.Vector3. (The reason why you don't have to do import UnityEngine in JS is because it has the UnityEngine namespace imported automatically, since it's written specifically for Unity and naturally you're going to be using the UnityEngine namespace almost all the time.)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ray-Pendergraph · Jul 28, 2010 at 07:36 PM 0
Share

I am asking does the fact that classes use namespaces other than the default negatively impact performance. I get fully qualifying classes in the code vs using and understand the JS scenario. Someone has made the assertion to me that "namespaces cause a degradation in performance" and I don't agree with that as a general statement. I understand there are caveats probably for reflection and some other instances, etc but the act of referencing a class from another namespace should not (or negligibly) affect performance. With the "using statement" or otherwise. But I wanted to get opinions.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Was UnityEngine.CrashLog deprecated with Unity 5.5.0? 0 Answers

How using additional namespaces affects performance? 1 Answer

Blender for Unity Publishing 0 Answers

Performance issue Raycast each frame 1 Answer

Raycast performance - 2 layers + 1 or 2 raycasts ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges