PHP, Zend Framework and Other Crazy Stuff
Performance Monitoring for ADOdb-Lite?
A while back I said I was thinking vaguely about adding performance monitoring into ADOdb-Lite. The news is that I started doing so today. The reasoning is fairly obvious – ADOdb’s perfmon library is a very useful tool even if it is underused, and I want to use it. Since nagging someone else about a feature I want is pointless (its open source!), I’m adding it myself – and hopefully well enough to see it in a release one day.
Day 1 was a two hour session taken up primarily in reading and understanding the ADOdb source code – man, it’s like wading through a bomb site at times. adodb.inc.php is huge! Anyways, I noted a few things and, just to make it clear, I was reading a July 2005 version (so anything noted by me could well have been changed since). Anyways, main points on Perfmon in ADOdb (as of July ’05):
- Perfmon is not workable with mysqli driver; there’s a small possible bug where the driver class supplies the $dataProvider property with the value “native”. Perfmon deliberately blocks this value – and the mysql driver uses the “mysql” value. So at the expense of some unknown issue and assuming what works for mysql qorks for mysqli, changing this to “mysqli” from “native” works fine.
- ADOdb output is escaped via htmlspecialchars(). Same as for ADOdb-Lite by default. Personally I prefer htmlentities() with ENT_QUOTES. Setting the character encoding is usually advisable to prevent charenc misinterpretations. Nag, nag, nag…![]()
- Output and PHP is mixed up. Never liked that, never will.
- Code uses the long names for superglobals – I don’t use old PHP versions, and I have the PHP6 CVS installed, so I’m changing that one for better or worse…
So after the reading I looked at what I needed to do. Given Perfmon is fairly standalone the simplest path is just to dump the code into ADOdb-Lite with minimal changes as follows:
- add a new property, $_logsql, to ADOConnection
- add a new method, LogSQL(), to ADOConnection
- stick the driver specific subclasses of the main perfmon class into the driver directory for each DBMS
- add a NewPerfMonitor() function to adodb.inc.php
Done, dust, test and finish… The approach isn’t part of the module system – like DataDictionary perfmon is called outside the connection object so that route seems to be of little real value. NewPerfMonitor() does all the legwork, and its use is pre-existing already if you use ADODB in code, so BC and all that prevailing…
I did a lot of the above in the second hour, tidied up and modified the source where necessary to make it ADOdb-Lite compatible, and ran a few tests. It still won’t work, but that’s for the moment because the $_logsql property acts as a switch which is, well, switched, on every query (to avoid logging the sql query FOR logging). It’s one of those confusing “track the value” puzzles I’m not up to getting my brain around at 11pm after having a few drinks earlier (rugby match – Ireland won over at Twickenham beating England for the Triple Crown – now if only Wales won…).
Tomorrow I’ll see about finishing it off, maybe tidying up output, and sticking a version online somewhere for someone else to look at and tell me what a bad lazy programmer I am…
. Anyways, perfmon for ADOdb-Lite, soon to be checked off my todo list.
Related posts:
| Print article | This entry was posted by Pádraic Brady on March 19, 2006 at 5:16 am, and is filed under PHP General. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
