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 /
avatar image
1
Question by jimbobuk · Feb 24, 2010 at 11:22 PM · iphoneperformancestring

Is it normal for string operations to be very expensive on the iPhone?

I kind of already know the answer to this from other platforms, but i've just recently been trying to optimise my project which had started to get very slow on my original iPhone. Developing on a 3GS can definitely hide things from you.

Anyways, a good chunk of this performance hit has something to do with my physics setup, i think i've got it about as optimised as possible now.

However i was left with a general amount of profiled mono scripts update.. 4-6% (of a frame i presume). Even when it was doing what I really expected to be nothing.

In the end i selectively removed functionality and went through the tedious rebuilding on the much slower older phone.

Finally figuring out that some of my debug functions were actually very expensive, even though their function bodies were disabled on a #define.

Basically what transpires is that just doing string ops like

Debug.Log("pos = " + transform.position);

can add a real significant percentage on the update, along with a corresponding decrease in framerate, and crucially a big increase in mono memory usage fluctuation. Large amounts of which seems to perhaps lead to more garbage collection and frame spikes.

Anyways, I just wanted to know if anyone had spotted this and had any tips for improvements. I've already disabled a lot of my debugging logs and other outputs. But i think i need to really look into a better way of removing them all on-mass, in absence of global #defines or C#'s ability to completely remove members on a #define. I'd hope the latter would remove any calculations on the calling side as well.

Anyways, it seems strings == very bad!

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
3
Best Answer

Answer by Jaap Kreijkamp · Feb 25, 2010 at 01:59 AM

A few things, accessing the transform using .transform does something like: (Transform)GetComponentOfType(typeof(Transform)) Better is to cache this value, do something like:

private Transform myTransform;

void Awake() { myTransform = transform; }

... Debug.Log("pos = " + myTransform.position); ...

(and of course us myTransform instead of transform everywhere in the class)

Also, the Vector3 is converted to a string, and then the result is added to the string. Then the Debug output is written to stdout, even if you're not capturing it, it does still consume time to write to the log.

Considder having a public static const bool DEBUG = false defined in some class (like Globals.cs or something) and use:

if (Globals.DEBUG) {
    Debug.Log(...)
}

Whenever doing things that are for debug purposes only, yes the compiler will compile const expressions away if they're false.

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

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

iTween iPhone Performance 4 Answers

Halo effect perfomance on mobile devices 1 Answer

iPhone 4 game lags 2 Answers

help with iphone 3GS performance (polys and audio) 2 Answers

Mobile bump performance 2 Answers


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