UnitTests: Use fmt::print in PageFaultTest
This commit is contained in:
parent
dd66dac5c1
commit
8fac249581
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Timer.h"
|
#include "Common/Timer.h"
|
||||||
|
@ -79,16 +80,19 @@ TEST(PageFault, PageFault)
|
||||||
perform_invalid_access(data);
|
perform_invalid_access(data);
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
#define AS_NS(diff) \
|
auto difference_in_nanoseconds = [](auto start, auto end) {
|
||||||
((unsigned long long)std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count())
|
return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
|
||||||
|
};
|
||||||
|
|
||||||
EMM::UninstallExceptionHandler();
|
EMM::UninstallExceptionHandler();
|
||||||
JitInterface::SetJit(nullptr);
|
JitInterface::SetJit(nullptr);
|
||||||
|
|
||||||
printf("page fault timing:\n");
|
fmt::print("page fault timing:\n");
|
||||||
printf("start->HandleFault %llu ns\n", AS_NS(pfjit.m_pre_unprotect_time - start));
|
fmt::print("start->HandleFault {} ns\n",
|
||||||
printf("UnWriteProtectMemory %llu ns\n",
|
difference_in_nanoseconds(start, pfjit.m_pre_unprotect_time));
|
||||||
AS_NS(pfjit.m_post_unprotect_time - pfjit.m_pre_unprotect_time));
|
fmt::print("UnWriteProtectMemory {} ns\n",
|
||||||
printf("HandleFault->end %llu ns\n", AS_NS(end - pfjit.m_post_unprotect_time));
|
difference_in_nanoseconds(pfjit.m_pre_unprotect_time, pfjit.m_post_unprotect_time));
|
||||||
printf("total %llu ns\n", AS_NS(end - start));
|
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));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue