Search Unity

Unity Script Performance

Discussion in 'Scripting' started by Programmer-David, Jul 2, 2015.

  1. Programmer-David

    Programmer-David

    Joined:
    Sep 17, 2012
    Posts:
    21
    Hi : )
    I'm running a script inside the unity editor, which executes an algorithm for graph rewriting.
    (A project for the university)
    It is not really game related, I'm just starting the scene to get a few output lines in the console.

    However, in visual studio the algorithm is finished ~3times faster then inside the unity editor.
    (unity: 0.48s, visual studio: 0.16s)

    I guess Unity might waste some cpu for engine-related tasks?
    Does anybody know, how to use more of the cpu/memory ressources just for the scripts?

    I took a look inside the profiler, but it just seems to record activity after the start of the scene.

    regards,
    Davud
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Code will always execute slower in the Editor as the Editor has overhead in and of itself.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The profiler has a "profile editor" button, if you're trying to profile an editor script.

    --Eric
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Outputting to the Unity console with Debug.Log or Print is slow. Each line outputted includes a complete stack trace, which slows things down a fair bit.