Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/libs/prx/libkernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,20 @@ if(BUILD_TESTING)
set_tests_properties(guest_posix_named_sem PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_wait_trace_tests ${LIBS_INCLUDE_DIR}/tests/GuestWaitTrace.cpp)
target_include_directories(guest_wait_trace_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_wait_trace_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_wait_trace_tests)
add_test(NAME guest_wait_trace COMMAND guest_wait_trace_tests)
set_tests_properties(guest_wait_trace PROPERTIES
ENVIRONMENT "APS5_TRACE_WAITS=1"
PASS_REGULAR_EXPRESSION "wait_trace_active_zero[^|]*x1"
FAIL_REGULAR_EXPRESSION "wait_trace_inactive[^|]*x0"
TIMEOUT 30)
if(WIN32)
set_tests_properties(guest_wait_trace PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_process_time_tests ${LIBS_INCLUDE_DIR}/tests/GuestProcessTime.cpp)
target_include_directories(guest_process_time_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_process_time_tests PRIVATE libkernel libc)
Expand Down
1 change: 1 addition & 0 deletions core/libs/prx/libkernel/Time/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void KernelTraceWait_nid_postfix(const char* kind, const void* caller, std::uint
if (now - lastReport < 3000000000ULL) return;
lastReport = now;
std::vector<std::pair<std::string, Site>> hot(sites.begin(), sites.end());
std::erase_if(hot, [](const auto& item) { return item.second.calls == 0; });
std::sort(hot.begin(), hot.end(), [](const auto& a, const auto& b) { return a.second.nanos > b.second.nanos; });
std::fprintf(stderr, "[waits]");
for (std::size_t i = 0; i < hot.size() && i < 8; ++i) {
Expand Down
16 changes: 16 additions & 0 deletions core/libs/tests/GuestWaitTrace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "prx/libkernel/Time/include/Time.hpp"
#include <array>
#include <chrono>
#include <thread>

int main() {
const std::array<int, 8> inactive{};
const int active = 0;
const int zeroDuration = 0;
for (const auto& site : inactive) KernelTraceWait_nid_postfix("wait_trace_inactive", &site, 1000000u, false);
std::this_thread::sleep_for(std::chrono::milliseconds(3100));
KernelTraceWait_nid_postfix("wait_trace_active", &active, 2000000u, false);
std::this_thread::sleep_for(std::chrono::milliseconds(3100));
KernelTraceWait_nid_postfix("wait_trace_active_zero", &zeroDuration, 0u, false);
return 0;
}
Loading