summaryrefslogtreecommitdiff
path: root/source3/profile
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-11-14 12:52:33 +0100
committerRalph Böhme <slow@samba.org>2015-03-06 12:31:10 +0100
commitb9f9869d1bec7cff6682d3cda774dcbb2464223b (patch)
tree2bb1d14b684945bd653398097214cdde33fdf9ca /source3/profile
parent74a16a1094278d2c5c8ac800a4f7ed4553d7ac85 (diff)
downloadsamba-b9f9869d1bec7cff6682d3cda774dcbb2464223b.tar.gz
s3:smbprofile: profile the system and user space cpu time
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/profile')
-rw-r--r--source3/profile/profile.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index 7002537354c..67b1fc765b9 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -22,12 +22,17 @@
#include "includes.h"
#include "system/shmem.h"
#include "system/filesys.h"
+#include "system/time.h"
#include "messages.h"
#include "smbprofile.h"
#include "lib/tdb_wrap/tdb_wrap.h"
#include <tevent.h>
#include "../lib/crypto/crypto.h"
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
struct profile_stats *profile_p;
struct smbprofile_global_state smbprofile_state;
@@ -260,6 +265,9 @@ void smbprofile_dump(void)
TDB_DATA key = { .dptr = (uint8_t *)&pid, .dsize = sizeof(pid) };
struct profile_stats s = {};
int ret;
+#ifdef HAVE_GETRUSAGE
+ struct rusage rself;
+#endif /* HAVE_GETRUSAGE */
TALLOC_FREE(smbprofile_state.internal.te);
@@ -267,6 +275,20 @@ void smbprofile_dump(void)
return;
}
+#ifdef HAVE_GETRUSAGE
+ ret = getrusage(RUSAGE_SELF, &rself);
+ if (ret != 0) {
+ ZERO_STRUCT(rself);
+ }
+
+ profile_p->values.cpu_user_stats.time =
+ (rself.ru_utime.tv_sec * 1000000) +
+ rself.ru_utime.tv_usec;
+ profile_p->values.cpu_system_stats.time =
+ (rself.ru_stime.tv_sec * 1000000) +
+ rself.ru_stime.tv_usec;
+#endif /* HAVE_GETRUSAGE */
+
ret = tdb_chainlock(smbprofile_state.internal.db->tdb, key);
if (ret != 0) {
return;