diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-03-13 22:12:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-03-13 22:13:02 +0900 |
| commit | 7348999caf3ce1e0be64697319581d52f1d7f8ea (patch) | |
| tree | 21f864b62825c79aa74c1ed935dfa801c00c42a6 /src | |
| parent | b89054b420235df9b9d7815bf9fad71e3b361395 (diff) | |
| download | php-waddiwasi-7348999caf3ce1e0be64697319581d52f1d7f8ea.tar.gz php-waddiwasi-7348999caf3ce1e0be64697319581d52f1d7f8ea.tar.zst php-waddiwasi-7348999caf3ce1e0be64697319581d52f1d7f8ea.zip | |
perf: log instruction metrics
Diffstat (limited to 'src')
| -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), |
