GetSimple "Memory Peak Usage" plugin

After reading this interesting article (about Wordpress vs gpEasy), I made this small and simple plugin to check GS's memory usage.

If enabled, the page's peak memory usage (in bytes) will be displayed at the bottom -- always in backend pages, in frontend only if logged in (GS 3.1+; in GS 3.0 or older it is always displayed unless the plugin is disabled)

Save the following code as memorypeakusage.php in your plugins folder.


// register plugin
$thisfile = basename(__FILE__, ".php");
    'Memory Peak Usage',
    'Carlos Navarro',
    'Displays PHP memory_get_peak_usage() value'

add_action('index-posttemplate','frontend_get_mgpu'); // frontend: only if logged in, or if GS version < 3.0
add_action('footer','get_mgpu'); // backend: always

function get_mgpu() {
    echo '<br />Memory Peak Usage: ', number_format(memory_get_peak_usage()), ' bytes<br />';

function frontend_get_mgpu() {
    global $USR;
    if (!function_exists('getChildrenMulti') || (isset($USR) && $USR == get_cookie('GS_ADMIN_USERNAME'))) {

// end of file

Suggestions and corrections welcome (or just fork and improve it if you wish)...

(First posted here)

0.1 start
0.1.1 slight change to detect version < 3.1

blog comments powered by Disqus