Results 1 to 10 of 12

Thread: Lags

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    If you suspect some code to be slow, just add some wait 0.05; in there (like, when if (i == 10) wait 0.05;), so the game engine has some time to care about the other events and later just resume the loops.

    Or generally, optimize the code. In computer science there is always more than one way to do stuff. To know what to optimize, there first need to be a profiler tho (or some good wild guesses). Probably would be a nice addition to measure time in all kinds of functions to create "fire graphs"... to see where it burns the most.

    Random idea I just got: make some function, which measueres the time till "last reset". So before entering performance critical code, the timer is reset. And IN the performance critical code, you can check all the time how much time was spend already, like in every loop body. If the time passed e.g. more than 10 milliseconds (which is quite alot, consider that a frame is only 50ms and there are others threads/coroutines which need to work aswell), then just "drop out" via wait 0.05 and reset the timer.
    timescale 0.01

  2. The Following User Says Thank You to kung foo man For This Useful Post:

    Lonsofore (26th April 2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •