[wing] Add wing_get_process_times
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [wing] Add wing_get_process_times
- Date: Wed, 29 Mar 2017 15:50:41 +0000 (UTC)
commit 1ba728820ebc586ad448b2b84b4d764e0b27e19a
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Wed Mar 29 11:11:25 2017 +0200
Add wing_get_process_times
wing/wingutils.c | 22 ++++++++++++++++++++++
wing/wingutils.h | 4 ++++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/wing/wingutils.c b/wing/wingutils.c
index 6b84933..17d8155 100644
--- a/wing/wingutils.c
+++ b/wing/wingutils.c
@@ -133,3 +133,25 @@ wing_get_process_memory (gsize *total_virtual_memory,
return res;
}
+
+static gint64
+get_time_from_filetime (const FILETIME *ft)
+{
+ gint64 t1 = (gint64)ft->dwHighDateTime << 32 | ft->dwLowDateTime;
+
+ return t1 / 10 - 11644473600000000; /* Jan 1, 1601 */
+}
+
+gboolean
+wing_get_process_times (gint64 *current_user_time,
+ gint64 *current_system_time)
+{
+ FILETIME creation_time, exit_time, kernel_time, user_time;
+
+ GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, &kernel_time, &user_time);
+
+ *current_user_time = get_time_from_filetime (&user_time);
+ *current_system_time = get_time_from_filetime (&kernel_time);
+
+ return TRUE;
+}
diff --git a/wing/wingutils.h b/wing/wingutils.h
index 42d54b0..4f27050 100644
--- a/wing/wingutils.h
+++ b/wing/wingutils.h
@@ -40,6 +40,10 @@ WING_AVAILABLE_IN_ALL
gboolean wing_get_process_memory (gsize *total_virtual_memory,
gsize *total_physical_memory);
+WING_AVAILABLE_IN_ALL
+gboolean wing_get_process_times (gint64 *current_user_time,
+ gint64 *current_system_time);
+
G_END_DECLS
#endif /* WING_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]