Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Adds profile report

AuthorDave Jarvis <email>
Date2026-02-09 22:17:35 GMT-0800
Commit3b6e6def123907fcc9651474171d1de1212af36b
Parentc4c5f11
Delta20 lines added, 3 lines removed, 17-line increase
Git.php
public function profileReport(): string {
if (empty($this->pStats)) {
- return "\n\n";
+ return "\nNo profiling data collected.\n";
}
// Sort by total time descending
- uasort( $this->pStats, fn($a, $b) => $b['time'] <=> $a['time'] );
+ uasort($this->pStats, fn($a, $b) => $b['time'] <=> $a['time']);
- $out = "\n\n";
+ $out = sprintf("\n%-35s | %6s | %9s | %9s\n", 'Method', 'Calls', 'Total(ms)', 'Avg(ms)');
+ $out .= str_repeat('-', 68) . "\n";
+
+ foreach ($this->pStats as $name => $stat) {
+ $totalMs = $stat['time'] * 1000;
+ $avgMs = $stat['cnt'] > 0 ? $totalMs / $stat['cnt'] : 0;
+
+ // Strip class name for cleaner output
+ $cleanName = str_replace(__CLASS__ . '::', '', $name);
+
+ $out .= sprintf("%-35s | %6d | %9.2f | %9.2f\n",
+ substr($cleanName, 0, 35),
+ $stat['cnt'],
+ $totalMs,
+ $avgMs
+ );
+ }
+
return $out;
}