• 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
0
Question by Nerethar · Sep 10, 2013 at 09:13 PM · c#performancecoroutine

Performance Issues with Coroutines

Hi guys,

I'm looking over my game with the Profiler to find some peaks and performance problems. One thing made me kinda curious. The end of a coroutine seemed to be a kinda big deal to unity so I made a trivial coroutine to verify that and here is the result:

alt text

The coroutine itself contains kinda trivial code:

     private IEnumerator TestRoutine(){
         yield return new WaitForSeconds(1f);
         print ("TESTTEST");
     }

I call the coroutine with StartCoroutine(TestRoutine());

Is that a common issue and is there a way to improve this? Because in the normal scenario I made at the end of that coroutine some other function calls what drove me up to 94% of the CPU usage. Of course I could use a yield for second after my function calls and delay that end of function a little, but that would not be an ideal solution. And almost 60% of CPU usage seems a little high for that task.

Thanks for any answers.

performance.png (77.3 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
4
Best Answer

Answer by Eric5h5 · Sep 10, 2013 at 09:16 PM

Remove the print statement. Debug.Log is quite CPU intensive; nothing to do with coroutines.

Comment
Add comment · Show 6 · 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 Nerethar · Sep 10, 2013 at 09:55 PM 0
Share

Thank you good sir! I couldn't belive my eyes that just removing print and debug lines saved 10% of one of my peaks oO

avatar image Eric5h5 · Sep 10, 2013 at 10:12 PM 1
Share

Yeah, you can't really have any Debug.Logs if you're trying to profile for performance. They go through the system, not just echoing text to the Unity console.

avatar image DDeathlonger Eric5h5 · May 09, 2018 at 04:28 AM 0
Share

Ohh debug.log actually logs to a file whereas print just echos info temp?

avatar image Eric5h5 DDeathlonger · May 09, 2018 at 04:34 AM 1
Share

No, print and Debug.Log are the same thing.

avatar image DDeathlonger · May 09, 2018 at 04:28 AM 0
Share

That was outstanding... I wonder why they leave Debug.Log available if it pulls so much... Seems quite silly.

avatar image Eric5h5 DDeathlonger · May 09, 2018 at 04:34 AM 1
Share

Because it's useful to have.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Reloading level or re-positioning player and objects? 2 Answers

Choppy Character Movement Unity 2D 0 Answers

constructing buildings rts style. 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