Improved callgrinding and added method for printing a visualization in the integration test

Recursive functions potentially cause some infinite loops in printing.