1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-09-01 21:07:24 +00:00

Add profile support: show function call time

This commit is contained in:
plt
2011-12-25 15:30:15 +08:00
parent 22479b384c
commit 0b0d51accd
3 changed files with 32 additions and 2 deletions

View File

@@ -10,6 +10,10 @@
#include "searpc-server.h"
#include "searpc-utils.h"
#ifdef PROFILE
#include <sys/time.h>
#endif
struct FuncItem;
typedef struct MarshalItem {
@@ -189,6 +193,11 @@ searpc_server_call_function (gchar *func, gsize len, gsize *ret_len, GError **er
JsonParser *parser;
JsonNode *root;
JsonArray *array;
#ifdef PROFILE
struct timeval start, end, intv;
gettimeofday(&start, NULL);
#endif
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -213,6 +222,13 @@ searpc_server_call_function (gchar *func, gsize len, gsize *ret_len, GError **er
gchar* ret = fitem->marshal->mfunc (fitem->func, array, ret_len);
#ifdef PROFILE
gettimeofday(&end, NULL);
timersub(&end, &start, &intv);
g_debug ("[searpc] Time spend in call %s: %ds %dus\n",
fname, intv.tv_sec, intv.tv_usec);
#endif
g_object_unref (parser);
return ret;