People sometimes ask how they can figure out what parts of their code might be slow.
The answer is “Well, you can use the glulxe profiler, but it’s annoying to do.” This is still true, unfortunately. (It requires using a couple of command-line tools, and browsing through your generated I6 code.) But if you’re writing a large game, you may have to do it anyhow.
I just did a profiling run on my (in progress) Hadean Lands code. According to the output, the function Prop_198 was eating a huge number of cycles. What was Prop_198? Turns out it was derived from this line of I7:
Definition: a container is empty rather than non-empty if nothing is in it.
This compiles as a test that loops through every thing to see if its parent is the given container. (My code currently has 412 things.)
I changed it to:
Definition: a container is empty rather than non-empty if the first thing held by it is nothing.
This compiles as a test that takes one line of I6. (Constant time, a couple of CPU cycles.)
I don’t have a moral here. Profiling is still no fun. The instructions are in the comments on github.com/erkyrath/glulxe/blob … analyze.py .