[llvm-commits] CVS: llvm/lib/System/Win32/Process.cpp
Reid Spencer
reid at x10sys.com
Sun Dec 19 16:59:39 PST 2004
Changes in directory llvm/lib/System/Win32:
Process.cpp updated: 1.2 -> 1.3
---
Log message:
For PR351: http://llvm.cs.uiuc.edu/PR351 :
* Implement GetMallocUsage to get usage of malloc heap
* Implement GetMemoryUsage to get total memory usage of process
* Implement GetTimeUsage to get elapsed/user/system time
---
Diffs of the changes: (+43 -0)
Index: llvm/lib/System/Win32/Process.cpp
diff -u llvm/lib/System/Win32/Process.cpp:1.2 llvm/lib/System/Win32/Process.cpp:1.3
--- llvm/lib/System/Win32/Process.cpp:1.2 Tue Nov 16 01:00:23 2004
+++ llvm/lib/System/Win32/Process.cpp Sun Dec 19 18:59:28 2004
@@ -41,5 +41,48 @@
return PageSize;
}
+void*
+uint64_t
+Process::GetMallocUsage()
+{
+#ifdef HAVE_MALLINFO
+ struct mallinfo mi = ::mallinfo();
+ return mi.uordblks;
+#warning Cannot get malloc info on this platform
+ return 0;
+#endif
+}
+
+uint64_t
+Process::GetTotalMemoryUsage()
+{
+#ifdef HAVE_MALLINFO
+ struct mallinfo mi = ::mallinfo();
+ return mi.uordblks + mi.hblkhd
+#else
+#warning Cannot get total memory size on this platform
+ return 0;
+#endif
+}
+
+void
+Process::GetTimeUsage(
+ TimeValue& elapsed, TimeValue& user_time, TimeValue& sys_time)
+{
+ elapsed = TimeValue::now();
+
+ unsigned __int64 ProcCreate, ProcExit, KernelTime, UserTime;
+ GetProcessTimes(GetCurrentProcess(), (FILETIME*)&ProcCreate,
+ (FILETIME*)&ProcExit, (FILETIME*)&KernelTime,
+ (FILETIME*)&UserTime
+ );
+
+ // FILETIME's are # of 100 nanosecond ticks (1/10th of a microsecond)
+ user_time.seconds( UserTime / 10000000 );
+ user_time.nanoseconds( (UserTime % 10000000) * 100 );
+ sys_time.seconds( KernelTime / 10000000 );
+ user_time.nanoseconds( (UserTime % 10000000) * 100 );
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
More information about the llvm-commits
mailing list