Skip to content

Commit ea5443a

Browse files
committed
use statistics interface
1 parent 53d09ef commit ea5443a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Collector/QueryLogger.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use GraphAware\Common\Cypher\StatementInterface;
88
use GraphAware\Common\Result\StatementResult as StatementResultInterface;
9+
use GraphAware\Common\Result\StatementStatistics;
10+
use GraphAware\Common\Result\StatementStatisticsInterface;
911

1012
/**
1113
* @author Xavier Coureau <[email protected]>
@@ -48,6 +50,7 @@ public function record(StatementInterface $statement)
4850
'query' => $statementText,
4951
'parameters' => $statementParams,
5052
'tag' => $statement->getTag(),
53+
'statistics' => []
5154
];
5255
$this->statementsHash[$statementText][$statementParams][$tag] = $idx;
5356
}
@@ -74,6 +77,7 @@ public function finish(StatementResultInterface $statementResult)
7477
$this->statements[$idx] = array_merge($this->statements[$idx], [
7578
'end_time' => microtime(true) * 1000,
7679
'nb_results' => $statementResult->size(),
80+
'statistics' => $this->statisticsToArray($statementResult->summarize()->updateStatistics())
7781
]);
7882
}
7983

@@ -118,4 +122,24 @@ public function getElapsedTime()
118122

119123
return $time;
120124
}
125+
126+
private function statisticsToArray(StatementStatisticsInterface $statementStatistics)
127+
{
128+
$data = [
129+
'contains_updates' => $statementStatistics->containsUpdates(),
130+
'nodes_created' => $statementStatistics->nodesCreated(),
131+
'nodes_deleted' => $statementStatistics->nodesDeleted(),
132+
'relationships_created' => $statementStatistics->relationshipsCreated(),
133+
'relationships_deleted' => $statementStatistics->relationshipsDeleted(),
134+
'properties_set' => $statementStatistics->propertiesSet(),
135+
'labels_added' => $statementStatistics->labelsAdded(),
136+
'labels_removed' => $statementStatistics->labelsRemoved(),
137+
'indexes_added' => $statementStatistics->indexesAdded(),
138+
'indexes_removed' => $statementStatistics->indexesRemoved(),
139+
'constraints_added' => $statementStatistics->constraintsAdded(),
140+
'constraints_removed' => $statementStatistics->constraintsRemoved()
141+
];
142+
143+
return $data;
144+
}
121145
}

Resources/views/webprofiler.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<div>
7777
<strong class="font-normal text-small">Number of results</strong>: {{ statement.nb_results }}
7878
</div>
79+
<div>
80+
<strong class="font-normal text-small">Statistics</strong>: {{ statement.statistics|yaml_encode }}
81+
</div>
7982
</div>
8083
</td>
8184
</tr>

0 commit comments

Comments
 (0)