Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Speed of new coroutines? — Gideros Forum

Speed of new coroutines?

test29test29 Member
edited July 2016 in General questions
How fast are new coroutines? Is it possible to write big part of game in it or they are slow for that?

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited July 2016 Accepted Answer
    They run a thousand bytecode instructions (I think) before checking for autoyield (and so on) - so they should be quite fast. That is the only difference in speed compared to a normal game running just the vsync.

    Modern cpus in phones are really fast anyhow so they should be fast enough - it really depends on the game.

    I'm trying to rig my code in Dungeons so that the coroutine is use for the monster sprite 'brains', I'll then yield manually if running too fast - or process the brains continuously if running too slow.

    The next version of Gideros has an extension I requested so that it makes doing this quite easy.

    Use framecounter to slow down your game code to the frame - eg something like this
    function game()
        while true do
            local currentFrame=Core.frameStatistics().frameCounter
            repeat
     
            do game code here...
     
            until currentFrame==Core.frameStatistics().frameCounter
            Core.yield(true)  -- wait if going too fast
        end
    end
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    I've updated the code above as I spoke to @hgy29 to make it nicer to use and a bit more future proofed by using a table.

    Likes: antix

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • john26john26 Maintainer
    We've had a report from @totebo, one of our major devs, that the speed is about the same with coroutines as without using them

    http://giderosmobile.com/forum/discussion/comment/48685#Comment_48685

    So it should be practical to use coroutines extensively.
  • totebototebo Member
    True dat. Love my new "major dev" status, thanks @john26. :)
    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.