Easy: extend or encapsulate the PDO and PDOStatement classes and use that for all database access, rather than the outdated mysql_ functions. You basically want your central query function(s) to be wrapped with two microtime calls, storing the difference on the object.
Mm... I'm not sure I like jmraker's solution much. As proof of concept, it's fine: microtime_float is necessary. But there are two things wrong with using SQLTimer in practice. First, it shouldn't use "echo", it should store the result in a variable, since ideally you'd be able to turn the debug output on or off at will, and you never know at what point the "echo" is going to happen. Worst case, it happens before essential headers are sent. You should preferably use a member variable, but since you're not using OOP here it would have to be either a global variable or a parameter by-reference variable. Second, it shouldn't use mysql_query - that relies too much on MySQL. Better to use the PDO class for all database access.