November 16, 2010

PHP StopWatch Class

Just a simple little class to play around with. I quickly threw it together because I got fed up of writing performance debugging code into perfectly clean classes, and then having to strip it out again later. The stop watch allows you to set callback methods to receive any calls to the stopwatches mark method, which as it’s a singleton can be called just about anywhere. Additionally it uses sprintf() strings to format the message and time.

Additionally this shows how in two lines you can be notified of the scripts entire execution time using StopWatch.
1