Speed-testing i7 story

I have a rather complex WIP with lots of NPC tracking.
Because of this, the story runs rather slowly, with lag times of up to three seconds between accepting a command and printing the results to the screen (this is on an Intel Core i5 w/ 8GB of ram).

I’m wondering if anyone can think of a way to reliably detect which parts of my code are the biggest time hogs.
Is there any conceivable way to use a real-world timer inside of i7? My idea was to print out the current time at the beginning and end of certain computationally heavy rules/actions so that I can debug out what’s taking so long.

Has anyone tried this anything like this before? Is it even possible to speed-optimize a story?

See discussion in this thread: https://intfiction.org/t/inform-7s-lack-of-speed/2842/1

It is possible to build a Glulx interpreter with profiling, if you’re comfortable compiling C code. This is your best shot for getting a detailed view of what’s slow.

However, it’s not too hard to figure out what’s going on without that. You can comment out your NPC every-turn rules and see if that changes the behavior. If it does, look at what you’re doing and think about whether it’s expensive.