Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Profiling time consumption on method calls
- - By SPK Date 2013-12-31 06:25
I need an easy way to determine how long my methods take, because some parts of my game became really slow and I want to know where the bottleneck is.
I already wrapped a few methods with t = ; puts - t, but I want/need it for every method call. Is it possible without touching everything?
Parent - - By RunnerPack Date 2013-12-31 07:05
Whenever you need to do something in Ruby, check first. It's pretty easy to filter out the Rails noise and find what you're after. I found MethodProfiler after a quick browse, but if that doesn't get the job done, there are a few other likely suspects.
Parent - - By SPK Date 2013-12-31 18:06 Edited 2013-12-31 18:48
Hi, thanks for the reply.
Okay, I tried MethodProfiler, but it doesn't go "deep" enough.
It tells me that:
| Method               | Min Time  | Max Time   | Average Time | Total Time  | Total Calls |
| #draw                | 1.879 ms  | 990.261 ms | 14.404 ms    | 4148.327 ms | 288         |

takes the longest. Even though only the first time? I already got this far before. However, I don't know why.
What does draw call to be that slow?

Edit: ruby-prof gives a lot more output. I'll give it a closer look.
Parent - - By SPK Date 2013-12-31 21:44
I never expected it to come down to this, but the real culprit is ... Gosu::Font#draw!
The #draw calls take one second during start... That's ridiculous.

Okay, here's the deal:
All my font objects used the Gosu::default_font_name font. As you see above it's insanely slow.
Then I  changed to "Droid Sans" and there it is... ~0.2 seconds. I *could* imagine that has something to do with them, because
I installed them recently and they basically touch everything font related.

Well, now I have wasted a day for something stupid again. :P

Happy new year!
Parent - By jlnr (dev) Date 2014-01-01 04:09
One second is crazy/scary :S But if you use a lot of Gosu::Font instances, it can really be worth the trouble to call text_width('ABC...all used letters here...XYZ') on them, to cache all relevant glyphs.
Up Topic Gosu / Gosu Exchange / Profiling time consumption on method calls

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill