Skip to Content


Finalize Nebula timings by adding total execution measurements and add times within each category.

PHP March 7, 2018


This function runs automatically, so it is not called manually. Is this incorrect?

Additional Notes

By calling this function you may prematurely end full execution timings and decrease accuracy. It’s best to let Nebula call this when it is ready.

Was this page helpful? Yes No

    A feedback message is required to submit this form.

    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Utilities/Utilities.php on line 1330.

    1 Hook

    Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.

    Need a new filter hook? Request one here.

    This function has no action hooks available. Request one?

            public function finalize_timings(){
                //Add category times together
                if ( !empty($this->server_timings['categories']) ){
                    foreach ( $this->server_timings['categories'] as $category => $times ){
                        if ( count($times) > 1 ){
                            $this->server_timings[$category . ' [Total]'] = array('time' => array_sum($times));
                //Pre-Nebula WordPress Core Time
                $this->server_timings['WordPress Core'] = array(
                    'start' => WP_START_TIMESTAMP,
                    'end' => $this->time_before_nebula,
                    'time' => $this->time_before_nebula-WP_START_TIMESTAMP
                //Database Queries
                global $wpdb;
                $total_query_time = 0;
                if ( !empty($wpdb->queries) ){
                    foreach ( $wpdb->queries as $query ){
                        $total_query_time += $query[1];
                    $this->server_timings['DB Queries [Total]'] = array('time' => $total_query_time);
                //Resource Usage
                $resource_usage = getrusage();
                //System resource usage timing
                $this->server_timings['PHP System'] = array(
                    'start' => $this->super->server['REQUEST_TIME_FLOAT'],
                    'end' => $this->super->server['REQUEST_TIME_FLOAT']+($resource_usage['ru_stime.tv_usec']),
                    'time' => $resource_usage['ru_stime.tv_usec']/1000000 //PHP 7.4 use numeric separators here
                //User resource usage timing
                $this->server_timings['PHP User'] = array(
                    'start' => $this->super->server['REQUEST_TIME_FLOAT'],
                    'end' => $this->super->server['REQUEST_TIME_FLOAT']+($resource_usage['ru_utime.tv_usec']),
                    'time' => $resource_usage['ru_utime.tv_usec']/1000000 //PHP 7.4 use numeric separators here
                //Add Nebula total
                $this->server_timings['Nebula [Total]'] = array(
                    'start' => $this->time_before_nebula,
                    'end' => microtime(true),
                    'time' => microtime(true)-$this->time_before_nebula
                //Total PHP execution time
                $this->server_timings['PHP [Total]'] = array(
                    'start' => $this->super->server['REQUEST_TIME_FLOAT'],
                    'end' => microtime(true),
                    'time' => microtime(true)-$this->super->server['REQUEST_TIME_FLOAT']
                return apply_filters('nebula_finalize_timings', $this->server_timings); //Allow functions/plugins to add/modifiy timings


    This function can not be short-circuited with an override filter. Request one?