This code will help you write command line tools with PHP that let you know the time elapsed and remaining time for a given script, and the script's memory usage as welll.