//fancy math for calculating cost in ms from tick_usage percentage and the length of ticks
//percent_of_tick_used * (ticklag * 100(to convert to ms)) / 100(percent ratio)
//collapsed to percent_of_tick_used * tick_lag
#define TICK_USAGE_TO_MS(percent_of_tick_used) (percent_of_tick_used * world.tick_lag)
Limitations:
Doesn't work on timing anything that sleeps mid run or runs for more than like 2 ticks or so (at some point it seems to reset even if no new tick happens)
It's accuracy is about a few ms, depending on unknown factors