UnitTests: Use fmt::print in PageFaultTest

This commit is contained in:
Pokechu22 2022-06-13 17:20:13 -07:00
parent dd66dac5c1
commit 8fac249581
1 changed files with 12 additions and 8 deletions

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <chrono>
#include <fmt/format.h>
#include "Common/CommonTypes.h"
#include "Common/Timer.h"
@ -79,16 +80,19 @@ TEST(PageFault, PageFault)
perform_invalid_access(data);
auto end = std::chrono::high_resolution_clock::now();
#define AS_NS(diff) \
((unsigned long long)std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count())
auto difference_in_nanoseconds = [](auto start, auto end) {
return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
};
EMM::UninstallExceptionHandler();
JitInterface::SetJit(nullptr);
printf("page fault timing:\n");
printf("start->HandleFault %llu ns\n", AS_NS(pfjit.m_pre_unprotect_time - start));
printf("UnWriteProtectMemory %llu ns\n",
AS_NS(pfjit.m_post_unprotect_time - pfjit.m_pre_unprotect_time));
printf("HandleFault->end %llu ns\n", AS_NS(end - pfjit.m_post_unprotect_time));
printf("total %llu ns\n", AS_NS(end - start));
fmt::print("page fault timing:\n");
fmt::print("start->HandleFault {} ns\n",
difference_in_nanoseconds(start, pfjit.m_pre_unprotect_time));
fmt::print("UnWriteProtectMemory {} ns\n",
difference_in_nanoseconds(pfjit.m_pre_unprotect_time, pfjit.m_post_unprotect_time));
fmt::print("HandleFault->end {} ns\n",
difference_in_nanoseconds(pfjit.m_post_unprotect_time, end));
fmt::print("total {} ns\n", difference_in_nanoseconds(start, end));
}