I would try using PHPs error_log() function:
$string = $hashed . " (total time: " . $totaltime . " seconds)" ;
error_log(print_r($string, true);
This will print your debug message to the PHP error log in real time without relying on the view layer of your application or interrupting the execution of your code. On a UNIX / Linux system or OS X you could tail the log. You could do this in windows too if you have Cygwin or another BASH emulator installed:
tail -f /path/to/your/error.log
You can use phpinfo() to determine the location of your PHP error log. If you have not specified custom settings for the log in your php.ini PHP will likely default to outputting errors to the Apache log.