So you want to know why your Python script is running slow?
There is an easy way to do this using cProfile and pstats, which count the number of calls to each function. We can visualize the results interactively in our web browser using snakeviz. You'll need to pip install snakeviz but the other two are included in the default Python libraries.
I originally had been searching for a way to do all this inside a single Python script within PyCharm, but after finding only solutions that involved moving over to the terminal to run snakeviz, I managed to solve this myself by looking through the snakeviz source code. I thought it would be beneficial to the community if I shared my recent discovery. See below for details of how to create a simple wrapper function and pass it across for speed testing.