Permalink
Browse files

Calculating ellapsed time for query on example logger

  • Loading branch information...
1 parent 5f71d42 commit c9bbec8869776752c946fcee2f1605de3a7b35c8 @mariano committed Jan 10, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 README.md
View
@@ -437,11 +437,20 @@ use Doctrine\DBAL\Logging\SQLLogger;
use li3_perf\extensions\util\Data;
class Li3PerfSQLLogger implements SQLLogger {
+ protected $query;
+ protected $start;
+
public function startQuery($sql, array $params = null, array $types = null) {
- Data::append('queries', array(compact('sql', 'params', 'types')));
+ $this->start = microtime(true);
+ $this->query = compact('sql', 'params', 'types');
}
public function stopQuery() {
+ $ellapsed = (microtime(true) - $this->start) * 1000;
+ Data::append('queries', array(array_merge(
+ array('explain' => array('millis' => $ellapsed)),
+ $this->query
+ )));
}
}

0 comments on commit c9bbec8

Please sign in to comment.