diff options
Diffstat (limited to 'src/Execution/Runtime.php')
| -rw-r--r-- | src/Execution/Runtime.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 40d7703..3617de2 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -21,8 +21,13 @@ use Nsfisis\Waddiwasi\Structure\Types\TableIdx; use Nsfisis\Waddiwasi\Structure\Types\ValType; use Nsfisis\Waddiwasi\Structure\Types\ValTypes; -final readonly class Runtime +final class Runtime { + /** + * @var array<string, int> + */ + private array $instrMetrics = []; + private function __construct( public readonly Store $store, public readonly Stack $stack, @@ -152,6 +157,15 @@ final readonly class Runtime } /** + * @return array<string, int> + */ + public function getInstrMetrics(): array + { + ksort($this->instrMetrics); + return $this->instrMetrics; + } + + /** * @param list<Val> $vals * @return list<Val> */ @@ -314,6 +328,9 @@ final readonly class Runtime static $debug = 0; // if ($debug >= 3) echo "Exec: " . $instr::opName() . "\n"; + // $this->instrMetrics[$instr::opName()] ??= 0; + // $this->instrMetrics[$instr::opName()]++; + return match ($instr::class) { Instrs\Numeric\F32Abs::class => $this->execInstrNumericF32Abs($instr), Instrs\Numeric\F32Add::class => $this->execInstrNumericF32Add($instr), |
