Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/stopwatch": "^4.4 || ^5.0 || ^6.0"
"symfony/stopwatch": "^4.4 || ^5.0 || ^6.0",
"symfony/service-contracts": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"atoum/atoum": "^4.0",
Expand Down
9 changes: 5 additions & 4 deletions src/TingBundle/DataCollector/TingCacheDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Symfony\Contracts\Service\ResetInterface;

class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface
class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface
{
/**
* @var CacheLoggerInterface|null
Expand Down Expand Up @@ -104,17 +105,17 @@ public function getCacheOperationsCount()

public function getCacheTotalTime()
{
return $this->data['cache']['time'];
return $this->data['cache']['time'] ?? 0;
}

public function getHits()
{
return $this->data['cache']['hits'];
return $this->data['cache']['hits'] ?? 0;
}

public function getMiss()
{
return $this->data['cache']['miss'];
return $this->data['cache']['miss'] ?? 0;
}

public function reset()
Expand Down
15 changes: 8 additions & 7 deletions src/TingBundle/DataCollector/TingDriverDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
use Symfony\Contracts\Service\ResetInterface;

class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface
class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface
{
/**
* @var DriverLoggerInterface|null
Expand Down Expand Up @@ -116,32 +117,32 @@ public function setDriverLogger(DriverLoggerInterface $driverLogger = null)

public function getQueryCount()
{
return $this->data['driver']['queryCount'];
return $this->data['driver']['queryCount'] ?? 0;
}

public function getQueries()
{
return $this->data['driver']['queries'];
return $this->data['driver']['queries'] ?? [];
}

public function getExecs()
{
return $this->data['driver']['execs'];
return $this->data['driver']['execs'] ?? [];
}

public function getTime()
{
return $this->data['driver']['time'];
return $this->data['driver']['time'] ?? 0;
}

public function getConnections()
{
return $this->data['driver']['connections'];
return $this->data['driver']['connections'] ?? [];
}

public function getConnectionsHashToName()
{
return $this->data['driver']['connectionsHashToName'];
return $this->data['driver']['connectionsHashToName'] ?? [];
}

public function reset()
Expand Down
12 changes: 11 additions & 1 deletion src/TingBundle/Logger/CacheLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
use CCMBenchmark\Ting\Logger\CacheLoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Contracts\Service\ResetInterface;

class CacheLogger implements CacheLoggerInterface
class CacheLogger implements CacheLoggerInterface, ResetInterface
{
protected $operationIndex = 0;
protected $operations = [];
Expand Down Expand Up @@ -126,4 +127,13 @@ public function getMiss()
{
return $this->miss;
}

public function reset(): void
{
$this->operationIndex = 0;
$this->operations = [];
$this->hits = 0;
$this->miss = 0;
$this->totalTime = 0;
}
}
14 changes: 13 additions & 1 deletion src/TingBundle/Logger/DriverLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
use CCMBenchmark\Ting\Logger\DriverLoggerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Contracts\Service\ResetInterface;

class DriverLogger implements DriverLoggerInterface
class DriverLogger implements DriverLoggerInterface, ResetInterface
{
/**
* @var null|LoggerInterface
Expand Down Expand Up @@ -253,4 +254,15 @@ public function getExecs()
{
return $this->execs;
}

public function reset(): void
{
$this->queries = [];
$this->execs = [];
$this->totalTime = 0;
$this->connections = [];
$this->connectionsHashToName = [];
$this->queryIndex = 0;
$this->execIndex = 0;
}
}
5 changes: 5 additions & 0 deletions src/TingBundle/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</service>

<service id="ting.driverlogger" synthetic="true" public="true">
<tag name="kernel.reset" method="reset" />
</service>

<service id="ting.connectionpool" class="CCMBenchmark\Ting\ConnectionPool" public="true">
Expand All @@ -42,12 +43,14 @@
<call method="setDatabaseOptions">
<argument>%ting.database_options%</argument>
</call>
<tag name="kernel.reset" method="reset" />
</service>

<service id="ting.unitofwork" class="CCMBenchmark\Ting\UnitOfWork" public="true">
<argument type="service" id="ting.connectionpool" />
<argument type="service" id="ting.metadatarepository" />
<argument type="service" id="ting.queryfactory" />
<tag name="kernel.reset" method="reset" />
</service>

<service id="ting.hydrator" class="CCMBenchmark\Ting\Repository\Hydrator" shared="false" public="true">
Expand Down Expand Up @@ -79,10 +82,12 @@

<service id="ting.driver_data_collector" class="CCMBenchmark\TingBundle\DataCollector\TingDriverDataCollector" public="true">
<tag name="data_collector" template="@Ting/Collector/driverCollector.html.twig" id="ting.driver" />
<tag name="kernel.reset" method="reset" />
</service>

<service id="ting.cache_data_collector" class="CCMBenchmark\TingBundle\DataCollector\TingCacheDataCollector" public="true">
<tag name="data_collector" template="@Ting/Collector/cacheCollector.html.twig" id="ting.cache" />
<tag name="kernel.reset" method="reset" />
</service>

<service id="ting.metadata_warmer" class="CCMBenchmark\TingBundle\Cache\MetadataWarmer" public="true">
Expand Down