# Query Count and Load Time in the Page Source

> Adds an HTML comment at the bottom of front-end and admin pages with the number of database queries, generation time and peak memory. Visible to administrators only.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: developer, performance, debugging, queries
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/performance-stats-comment/

## Code

```php
$wpide_stats_comment = function () {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }

    printf(
        "\n<!-- %d queries in %s seconds, peak memory %s -->\n",
        (int) get_num_queries(),
        esc_html( timer_stop( 0, 3 ) ),
        esc_html( size_format( memory_get_peak_usage( true ), 1 ) )
    );
};

add_action( 'wp_footer', $wpide_stats_comment, 9999 );
add_action( 'admin_footer', $wpide_stats_comment, 9999 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Query Count and Load Time in the Page Source" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
