2013-04-16 23:57:29 -04:00
|
|
|
#include "toku_portability.h"
|
2008-07-24 21:23:40 +00:00
|
|
|
#include "../include/rdtsc.h"
|
2013-04-16 23:57:19 -04:00
|
|
|
#include "trace_mem.h"
|
2008-07-24 21:23:40 +00:00
|
|
|
|
|
|
|
// customize this as required
|
2008-07-24 21:26:38 +00:00
|
|
|
#define NTRACE 0
|
2008-07-24 21:23:40 +00:00
|
|
|
#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
|
|
|
|
|
2013-04-16 23:57:20 -04:00
|
|
|
void toku_add_trace_mem (const char *str __attribute__((unused)),
|
|
|
|
int n __attribute__((unused))) {
|
2008-07-24 21:23:40 +00:00
|
|
|
#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
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:19 -04:00
|
|
|
void toku_print_trace_mem(void) {
|
2008-07-24 21:23:40 +00:00
|
|
|
#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
|
|
|
|
}
|