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
3
Question by Jason B · Nov 28, 2011 at 07:12 PM · performanceoptimizationupdateinvokerepeating

Any costs I should know about associated with InvokeRepeating?

Is there any real overhead associated with InvokeRepeating? I have something that runs in Update that I can easily get away with updating, say, 30 times per second instead of every single frame (which in most scenarios means it's being run about 150 times per second; which seems like I have a lot of excess frames to work with, but I'm making a physics game so I need to squeeze out as much performance as possible).

Keep in mind this is for simple "update counter text" type things, so the function itself that is being repeated isn't heavy, but I'm trying to maximize speed and wondering if InvokeRepeating has any inherent performance hits.

If there aren't any problems, I'm going to happily start migrating a bunch of things out of Update, where it seems wasteful to do them every single frame when there's no need.

Also, is there any difference between using coroutines and InvokeRepeating in terms of 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

1 Reply

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

Answer by Eric5h5 · Nov 28, 2011 at 07:48 PM

In terms of overhead, the order (from most to least) is Update, coroutines, then InvokeRepeating.

Comment
Add comment · Show 5 · 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 Jason B · Nov 28, 2011 at 08:56 PM 0
Share

Ah, that's surprising. Thank you.

avatar image Eric5h5 · Nov 28, 2011 at 09:17 PM 1
Share

Specifically, InvokeRepeating is about twice as efficient as a coroutine when it repeats, but the "wait" part for both has no appreciable overhead (as opposed to Update, which always has overhead).

avatar image Bovine · Dec 24, 2011 at 12:36 PM 0
Share

Really useful to know. I've been using coroutines a lot but end up yielding a new WaitForSeconds() each time and I think InvokeRepeating() feels like a better fit in these cases.

avatar image felixpk · Jul 25, 2015 at 06:48 PM 0
Share

Can I ask where you have this information from?

avatar image Eric5h5 · Jul 25, 2015 at 06:51 PM 0
Share

Running benchmarks.

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

convert timer from update() to coroutine or invokerepeating 0 Answers

Update with bool flag or script enabled/disabled? 2 Answers

How do I get my game to run faster? 4 Answers

InvokeRepeating VS Coroutines [Performance] 1 Answer

Is Instantiating bullets/many objects always bad for performance? 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