This week has been test, test, test, test with a lot of categories. To do the test with categories, I wrote code for another way of insert categories in mysql (without WordPress functions and MPTT functions), because the WP execution was stopped by php (stopped by max_time_execution and memory limit when I try to insert 20000 to 100000 categories).
The idea is get the inserts statements for to can do “one big insert” using only text, executing the script and insert directly to the database [ example: php -n insert-sql.php | mysql -u user -ppass wp_db]. The script is in mptt-test/insert-sql.php .
For get the speedup, I get the categories 5 times and calculate the time of execution with the code:
$start = microtime( true );
mptt_wp_dropdown_categories( $args );
$finish = microtime( true );
$total = $finish – $start;
The speedup is beetwen 7-10% with synthetic data (20000 to 100000 categories with depth 5), and real XML data. You can see the results in http://spreadsheets.google.com/pub?key=tWef2b-aEpdU5LOFwUe65DA&output=html .
Now, the code for categories goes ok (I coded a plugin that extends the core functions for test the mptt). When you install the mptt plugin, automatically add new fields of the database with metadata. In the admin panel you can view the tree of categories using mptt menu.
With mptt-test you can insert artificial data into database, for make test or benchmark the algorithm.
You can see the plugin code of mptt, mptt-test and little patch to core in http://files.getdropbox.com/u/173207/mptt-pack.zip (this pack have a bug) http://files.getdropbox.com/u/173207/pack_fixed.zip
Feel free for test, modified, reuse the code ;).