CORE: added some stats that getrusage gives us

master
Martin Gerhardy 2019-04-12 22:15:16 +02:00
parent 3bd9274012
commit dbc88c080b
3 changed files with 17 additions and 0 deletions

View File

@ -57,6 +57,7 @@ endif()
check_include_files("syslog.h" HAVE_SYSLOG_H)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
check_include_files("sys/resource.h" HAVE_SYS_RESOURCE_H)
check_include_files("sys/time.h" HAVE_SYS_TIME_H)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCKGETTIME)
if (HAVE_CLOCKGETTIME)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt")

View File

@ -17,6 +17,7 @@
#cmakedefine HAVE_SYS_RESOURCE_H 1
#cmakedefine HAVE_POSTGRES 1
#cmakedefine HAVE_UUID_H 1
#cmakedefine HAVE_SYS_TIME_H 1
#cmakedefine OPENCL_LIBRARY "@OPENCL_LIBRARY@"
#cmakedefine BASE_URL "@BASE_URL@"

View File

@ -19,6 +19,9 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
namespace core {
@ -600,6 +603,18 @@ AppState App::onCleanup() {
_metric->shutdown();
}
#if defined(HAVE_SYS_RESOURCE_H) and defined(HAVE_SYS_TIME_H)
struct rusage usage;
if (0 == getrusage(RUSAGE_SELF, &usage)) {
Log::info("Max resident set size used: %li kb", usage.ru_maxrss);
Log::info("Number of soft page faults: %li", usage.ru_minflt);
Log::info("Number of page faults: %li", usage.ru_majflt);
Log::info("Filesystem inputs: %li", usage.ru_inblock);
Log::info("Filesystem outputs: %li", usage.ru_oublock);
Log::info("System cpu time: %li ms", usage.ru_stime.tv_sec * 1000L + usage.ru_stime.tv_usec / 1000L);
Log::info("User cpu time: %li ms", usage.ru_utime.tv_sec * 1000L + usage.ru_utime.tv_usec / 1000L);
}
#endif
SDL_Quit();
return AppState::Destroy;