mariadb/newbrt/trace_mem.c
Yoni Fogel 049c7625a3 Addresses #1765 Merge [12079] into main (pthreads-win32 for windows)
git-svn-id: file:///svn/toku/tokudb@12081 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:53 -04:00

42 lines
1.3 KiB
C

#ident "$Id$"
#ident "Copyright (c) 2007, 2008, 2009 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <toku_portability.h>
#include "rdtsc.h"
#include "trace_mem.h"
// customize this as required
#define NTRACE 0
#if NTRACE
static struct toku_trace {
const char *str;
int n;
unsigned long long ts;
} toku_trace[NTRACE];
static int toku_next_trace = 0;
#endif
void toku_add_trace_mem (const char *str __attribute__((unused)),
int n __attribute__((unused))) {
#if USE_RDTSC && NTRACE
int i = toku_next_trace++;
if (toku_next_trace >= NTRACE) toku_next_trace = 0;
toku_trace[i].ts = rdtsc();
toku_trace[i].str = str;
toku_trace[i].n = n;
#endif
}
void toku_print_trace_mem(void) {
#if NTRACE
int i = toku_next_trace;
do {
if (toku_trace[i].str)
printf("%llu %s:%d\n", toku_trace[i].ts, toku_trace[i].str, toku_trace[i].n);
i++;
if (i >= NTRACE) i = 0;
} while (i != toku_next_trace);
#endif
}