cProfile compatible with game engine?


Anyone know if it’s possible to use something like cProfile to understand which aspects of our implementation take the most time?

It appears the Halite game engine has some restrictions around being profiled in this way. Maybe our best bet is to roll our own make-shift profiler tracking the number of times various functions are called and outputting this summary via logging? Any other suggestions?


You should be able to use a profiler on your bot (not on the engine itself), so long as you configure the profiler to write its results to a file and not to standard out/standard error. For instance, cProfile does that by default; you should configure it to dump results to a file.


Another way would be to replay the game state from each turn. This allows you to run the game outside of the game engine. It can be really helpful if you want to use a debugger, cProfile ect.


Thanks for the suggestions!


@fohristiwhirl has a tool to do exactly that: https://github.com/fohristiwhirl/halite3_reload