42 if ( isset( $this->params[
'perHost'] ) ) {
43 $this->perHost = $this->params[
'perHost'];
48 # Do not log anything if database is readonly (T7375)
52 public function log( array $stats ) {
60 $dbw->onTransactionCommitOrIdle(
function () use ( $stats, $fname, $dbw ) {
64 $useTrx = ( $dbw->getType() ===
'sqlite' );
67 $useTrx ? $dbw->startAtomic( $fname ) :
null;
69 foreach ( $stats as $data ) {
70 $name = $data[
'name'];
71 $eventCount = $data[
'calls'];
72 $timeSum = (float)$data[
'real'];
73 $memorySum = (float)$data[
'memory'];
74 $name = substr( $name, 0, 255 );
77 $timeSum = $timeSum >= 0 ? $timeSum : 0;
78 $memorySum = $memorySum >= 0 ? $memorySum : 0;
80 $dbw->upsert(
'profiling',
83 'pf_count' => $eventCount,
84 'pf_time' => $timeSum,
85 'pf_memory' => $memorySum,
86 'pf_server' => $pfhost
88 [ [
'pf_name',
'pf_server' ] ],
90 "pf_count=pf_count+{$eventCount}",
91 "pf_time=pf_time+{$timeSum}",
92 "pf_memory=pf_memory+{$memorySum}",
102 $useTrx ? $dbw->endAtomic( $fname ) :
null;