Skip to content

Commit

Permalink
Fix DataCollector return types
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Nov 27, 2023
1 parent 7989f27 commit 1409bda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public function getRenderCount(): int
return $this->data['render_count'] ?? 0;
}

public function getRenderTime(): int
public function getRenderTime(): float
{
return $this->data['render_time'] ?? 0;
return (float) ($this->data['render_time'] ?? 0);
}

private function collectDataFromLogger(): void
Expand Down Expand Up @@ -149,7 +149,7 @@ private function collectDataFromLogger(): void
$renders[$renderId] += [
'render_end' => $profile[0],
'render_time' => $renderTime,
'render_memory' => $profile[1],
'render_memory' => (int) $profile[1],
];

++$components[$componentName]['render_count'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<span class="sf-toolbar-value">{{ collector.renderCount }}</span>
<span class="sf-toolbar-info-piece-additional-detail">
<span class="sf-toolbar-label">in</span>
<span class="sf-toolbar-value">{{ collector.renderTime }}</span>
<span class="sf-toolbar-value">{{ collector.renderTime|round }}</span>
<span class="sf-toolbar-label">ms</span>
</span>
{% endset %}
Expand Down Expand Up @@ -165,7 +165,7 @@
<div class="metric-divider"></div>
<div class="metric-group">
{{ _self.metric(collector.renderCount, "Render Count") }}
{{ _self.metric(collector.renderTime, "Render Time", "ms") }}
{{ _self.metric(collector.renderTime|round, "Render Time", "ms") }}
</div>
<div class="metric-divider"></div>
<div class="metric-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testLateCollect(): void
$this->assertIsIterable($dataCollector->getRenders());
$this->assertEmpty($dataCollector->getRenders());

$this->assertSame(0, $dataCollector->getRenderTime());
$this->assertEquals(0.0, $dataCollector->getRenderTime());
}

public function testReset(): void
Expand Down

0 comments on commit 1409bda

Please sign in to comment.