Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Debug.Log is slowing down loop. Any alternatives?

Discussion in 'Scripting' started by dansav, Mar 3, 2010.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I have something like this going on.

    for(i=0;i<500;i++){
    for(k=0;k<500;k++){

    Inside is a Debug Log to see what's happening.
    }
    }

    If the Debug.Log is in there then it runs like 1000 times slower. Is there an alternative to Debug.Log that is faster?

    Thanks,

    Dan
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Add info to a string instead of using Debug.Log, then print the string when the loops are ended.

    --Eric
     
  3. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    Good Idea.

    Thanks

    Dan