[wp-hackers] Dynamic Includes

Robert Deaton false.hopes at gmail.com
Fri Oct 7 01:22:30 GMT 2005


I think that either dynamic includes, or at the very least a
reorganization of file includes would be great. On my own time I've
done some APD runs on the WordPress code, and consistantly about 60%
of the time for loading any page was on including files and declaring
functions. WordPress currently has 982 functions [1] of which a
considerable amount are loaded on every pageload. I'm up for any way
of cutting back on this, and I've often thought of something about
exactly what Andy posted but never got around to writing about such a
system.

Later on, I'll run some more apd tests with a varying number of themes
and try to track down exactly which functions are loaded and where
some things could be cut out, moved around, or moved to a system like
Andy suggested.

[1] http://somethingunpredictable.com/xrefs/wptrunk/nav.html?index.html

On 10/6/05, Andy Skelton <skeltoac at gmail.com> wrote:
> This may or may not be a bright idea, which is why I'm sending it
> 'round. WP might be sped up by reducing the number of includes and/or
> leaving big functions out of the core. Here's a possibililty:
>
> --- begin wp-functions.php
> <?php
> // Functions and the files that declare them, next on Jerry
> $wp_functions = array(
>     '_wp_simple_function' => '/functions-meta.php',
>     '_wp_passref_function' => '/comment-functions.php',
>     '_wp_returnref_function' => '/comment-functions.php',
>     ...
> );
>
> // Function includer for... including functions.
> function wp_include_function($func) {
>     if ( ! function_exists($func) )
>         require_once(ABSPATH . WPINC . $wp_functions["$func"]);
> }
>
> // function wrapper for no-reference function (args are copies)
> function wp_simple_function() {
>     wp_include_function('_wp_simple_function');
>     $args = func_get_args();
>     return call_user_func_array('_wp_simple_function', $args);
> }
>
> // Function wrapper for pass-by-reference function (args are references)
> function wp_passref_function(&$arg1, &$arg2) {
>     wp_include_function('_wp_passref_function');
>     return _wp_passref_function($arg1, $arg2);
> }
>
> // Function wrapper for return-reference function (returns a reference)
> function &wp_returnref_function() {
>     wp_include_function('_wp_returnref_function');
>     $args = func_get_args();
>     return call_user_func_array('_wp_returnref_function', $args);
> }
> --- end wp-functions.php
>
> The files in wp-includes would then declare the functions with an
> underscore prepended to the name. This might be worthwhile for some of
> the less-used core includes, but certainly not the entire set. It
> would be a heluvan overhaul, so methinks 1.6 would be out of the
> question. Let fly the opinions.
>
> Andy Skelton
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


--
--Robert Deaton
http://somethingunpredictable.com


More information about the wp-hackers mailing list