From 7ef6cdb515ef8641e66381d8a1e5df9b4beeef7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 7 Jun 2024 10:00:02 +0200 Subject: [PATCH] Improve accuracy of block timing --- Core/MIPS/IR/IRJit.cpp | 13 ++++++------- Core/MIPS/IR/IRJit.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/MIPS/IR/IRJit.cpp b/Core/MIPS/IR/IRJit.cpp index 4205272135..3a9b15f542 100644 --- a/Core/MIPS/IR/IRJit.cpp +++ b/Core/MIPS/IR/IRJit.cpp @@ -256,13 +256,12 @@ void IRJit::RunLoopUntil(u64 globalticks) { if (opcode == MIPS_EMUHACK_OPCODE) { u32 offset = inst & 0x00FFFFFF; // Alternatively, inst - opcode #ifdef IR_PROFILING - { - TimeSpan span; - IRBlock *block = blocks_.GetBlock(blocks_.GetBlockNumFromOffset(inst & 0xFFFFFF)); - mips->pc = IRInterpret(mips, blocks_.GetArenaPtr() + offset); - block->profileStats_.executions += 1; - block->profileStats_.totalNanos += span.ElapsedNanos(); - } + IRBlock *block = blocks_.GetBlock(blocks_.GetBlockNumFromOffset(offset)); + TimeSpan span; + mips->pc = IRInterpret(mips, blocks_.GetArenaPtr() + offset); + int64_t elapsedNanos = span.ElapsedNanos(); + block->profileStats_.executions += 1; + block->profileStats_.totalNanos += elapsedNanos; #else mips->pc = IRInterpret(mips, blocks_.GetArenaPtr() + offset); #endif diff --git a/Core/MIPS/IR/IRJit.h b/Core/MIPS/IR/IRJit.h index c6d09af12e..81d97925c7 100644 --- a/Core/MIPS/IR/IRJit.h +++ b/Core/MIPS/IR/IRJit.h @@ -103,6 +103,7 @@ private: u64 CalculateHash() const; // Offset into the block cache's Arena + // TODO: These should maybe be stored in a separate array. u32 instOffset_ = 0; u64 hash_ = 0; u32 origAddr_ = 0;