Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by michael_c85 · Aug 23, 2016 at 06:25 PM · editorperformance

Performance using int over float in editor

I'm asking this out of curiosity, it may seem minor ;)

Would using whole numbers in the attached example (or transform, etc) offer any performance gain across a project?

capture.png (10.7 kB)
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

1 Reply

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

Answer by Graphics_Dev · Aug 23, 2016 at 05:15 PM

This is a duplicate question. You can read these posts about the topic (this is by no means exhaustive):

http://answers.unity3d.com/questions/528607/floats-and-int-performance-difference.html

In short, the general consensus seems to be "it depends". My personal opinion is that in games, this kind of optimization is useless. Your time would be better spent optimizing your memory allocations (reducing garbage) or moving unnecessary computation out of the Update function.

http://forum.unity3d.com/threads/int-vs-float.64290/

Doing basic math operations with int is around 30% faster than float. If you need to save RAM and your integer numbers are small enough, you can use short (System.Int16) or even byte instead of int, however int32 is a little faster than both. On a desktop CPU anyway; not sure about ARM. Oh yeah, and certain operations like various bitwise operators can only be done on integers.

Comment
Add comment · Show 7 · 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 michael_c85 · Aug 23, 2016 at 05:38 PM 0
Share

Thanks for the fast reply.

Do you know if this is true for in-editor variables? (i.e. are editor variables always float or is the type dynamic).

avatar image Graphics_Dev michael_c85 · Aug 23, 2016 at 06:43 PM 0
Share

I do not know...I would assume it is not always stored as a float, but I don't know for sure. By in-editor you mean variables for editor scripts?

If this answered your question please accept my answer.

avatar image michael_c85 Graphics_Dev · Aug 23, 2016 at 07:17 PM 0
Share

I mean all the position values in transform, etc. or in attached photo above the offset and size. Generally whenever putting a value in the editor without being explicit about what type you are using.

I was wondering if it would be worth me adjusting them to whole values or if there was no performance implication.

Does this make sense?

Show more comments
avatar image michael_c85 · Aug 25, 2016 at 08:27 AM 0
Share

thank you @ByteSheep

avatar image Graphics_Dev michael_c85 · Aug 25, 2016 at 02:12 PM 0
Share

Please don't leave comments as answers in the future.

I fixed it for you this time :-)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Entering playmode from editor is very slow 0 Answers

Low fps in scene editor and game view 1 Answer

Why does my Scene View use 100% processor 0 Answers

Scene view performance 0 Answers

5.4 GB of RAM used by editor. 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