Modifying definition of Timer#memory_size on Linux to become resident size.

This commit is contained in:
Matthias Koefferlein 2025-03-23 18:46:15 +01:00
parent db728dc68a
commit e6ff30adee
2 changed files with 9 additions and 4 deletions

View File

@ -147,7 +147,11 @@ Class<tl::Timer> decl_Timer ("tl", "Timer",
gsi::method ("memory_size", &tl::Timer::memory_size,
"@brief Gets the current memory usage of the process in Bytes\n"
"\n"
"This method has been introduced in version 0.27."
"The returned value is the resident memory size on Linux and MacOS and "
"the working set size on Windows.\n"
"\n"
"This method has been introduced in version 0.27. The value has been changed "
"to be resident size (instead of virtual size) on Linux in version 0.30."
) +
gsi::method ("user", &tl::Timer::sec_user,
"@brief Returns the elapsed CPU time in user mode from start to stop in seconds\n"

View File

@ -245,8 +245,8 @@ Timer::memory_size ()
"%*d " // 0
"%*d " // itrealvalue
"%*u " // starttime
"%lu " // vsize
"%*d " // rss
"%*u " // vsize
"%lu " // rss
"%*u " // rlim
"%*u " // startcode
"%*u " // endcode
@ -270,7 +270,8 @@ Timer::memory_size ()
memsize = 0;
}
}
return size_t (memsize);
return size_t (memsize) * size_t (getpagesize ());
#else
# error Unsupported platform