35 lines
629 B
PHP
35 lines
629 B
PHP
<?php
|
|
|
|
namespace KupShop\MetricsBundle\Util;
|
|
|
|
use Doctrine\DBAL\Logging\SQLLogger;
|
|
|
|
/**
|
|
* Includes executed SQLs in a Debug Stack.
|
|
*/
|
|
class SQLTimeLogger implements SQLLogger
|
|
{
|
|
/** @var float|null */
|
|
public $start;
|
|
|
|
/** @var int */
|
|
public $currentQuery = 0;
|
|
|
|
/** @var float */
|
|
public $time = 0.;
|
|
|
|
/** @var int */
|
|
public $count = 0;
|
|
|
|
public function startQuery($sql, ?array $params = null, ?array $types = null)
|
|
{
|
|
$this->start = \microtime(true);
|
|
$this->count++;
|
|
}
|
|
|
|
public function stopQuery()
|
|
{
|
|
$this->time += \microtime(true) - $this->start;
|
|
}
|
|
}
|