1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

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>
This commit is contained in:
Stefan Metzmacher 2014-11-14 12:52:33 +01:00 committed by Ralph Böhme
parent 74a16a1094
commit b9f9869d1b
3 changed files with 25 additions and 0 deletions

View File

@ -32,6 +32,8 @@ struct tevent_context;
SMBPROFILE_STATS_COUNT(connect) \
SMBPROFILE_STATS_COUNT(disconnect) \
SMBPROFILE_STATS_BASIC(idle) \
SMBPROFILE_STATS_TIME(cpu_user) \
SMBPROFILE_STATS_TIME(cpu_system) \
SMBPROFILE_STATS_COUNT(request) \
SMBPROFILE_STATS_BASIC(push_sec_ctx) \
SMBPROFILE_STATS_BASIC(set_sec_ctx) \

View File

@ -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;

View File

@ -1484,6 +1484,7 @@ main() {
if Options.options.with_profiling_data:
conf.DEFINE('WITH_PROFILE', 1);
conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
if Options.options.with_pthreadpool:
if conf.CONFIG_SET('HAVE_PTHREAD'):