How To Check Your Plugins For Performance
Warning: Advanced tutorial - for developers only.
We all love the new product & plugins system that was introduced in vbulletin. No more doing file modifications, no more writing a lot of instructions in a long txt and following them for an hour to install a hack, just upload the product, run.. ready (with some exceptions, of course). I found myself trying to find a "good" method for checking my plugins for performance. After all, I don't want a hack or modification going wild and slowing my whole forum. I seriously needed to find a way to find out how much resources my plugins were using. And, while developing, I wanted to make sure that I didn't have "bad code" that used too many resources. We already had the solution, for logging the page load time, a microtime() is used. Why not do it with every hook as well, then we could check the statistics and if a hook is taking too much time to execute, disable it, or reprogram it. Gettings these statistics is a simple modification. 1) We'll need to create a new table, run the following query (add your table prefix if necessary): Code:
CREATE TABLE hookstats ( PHP Code:
PHP Code:
3) Open a couple pages on which the plugins are used. Browse a while. We need the plugins to be executed before checking the stats! 4) Run the following query on your favorite sql client, phpmyadmin, the console, or wherever you want to check the stats (add the table prefix if necessary): Code:
SELECT Code:
+-------------------------------+---------------------+ You can check the average execution time for every hook. These are the average execution times for each hook on your forum. Of course, what you probably needed was the execution time for a plugin, or a product, not the whole hook. Doing so is out of the scope of this tutorial, this technique shouldn't be so difficult to extend for logging the time per plugin or per product. For now, seeing the information per hook is useful and a good start. The irony? Try not to use this on a production environment since logging in the database takes some resources. You are adding a lot of queries, 2 per hook. This should be used whenever you need to benchmark performance, test your mod, and disabled after. |
that's a handy little routine. thanks for sharing, it will be put to good use.
|
one thing isnt correkt
you make a table hookstats but you insert things into ".TABLE_PREFIX."hookstats ;) so use just one |
All times are GMT. The time now is 05:06 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|