From 44f5eb882bcaab2f5a19a0d7680929d6b0463f62 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 14 Mar 2024 00:18:17 +0900 Subject: perf: log instr metrics --- src/Execution/Runtime.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Execution/Runtime.php') diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 5f04978..fa1689a 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -157,7 +157,7 @@ final class Runtime */ public function getInstrMetrics(): array { - ksort($this->instrMetrics); + asort($this->instrMetrics); return $this->instrMetrics; } @@ -324,10 +324,9 @@ final class Runtime static $debug = 0; // if ($debug >= 3) echo "Exec: " . $instr::opName() . "\n"; - // $this->instrMetrics[$instr::opName()] ??= 0; - // $this->instrMetrics[$instr::opName()]++; + // $start = hrtime(true); - return match ($instr::class) { + $result = match ($instr::class) { Instrs\Numeric\F32Abs::class => $this->execInstrNumericF32Abs($instr), Instrs\Numeric\F32Add::class => $this->execInstrNumericF32Add($instr), Instrs\Numeric\F32Ceil::class => $this->execInstrNumericF32Ceil($instr), @@ -534,6 +533,11 @@ final class Runtime Instrs\Control\Unreachable::class => $this->execInstrControlUnreachable($instr), default => throw new \RuntimeException("invalid instruction"), }; + + // $this->instrMetrics[$instr::opName()] ??= 0; + // $this->instrMetrics[$instr::opName()] += hrtime(true) - $start; + + return $result; } private function execInstrNumericF32Abs(Instrs\Numeric\F32Abs $instr): void -- cgit v1.2.3-70-g09d2