mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
Count the number of mallocs of different sizes
git-svn-id: file:///svn/tokudb@93 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
17fc9acfa8
commit
f94ef8fc9d
3 changed files with 17 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
/* Insert a bunch of stuff */
|
/* Insert a bunch of stuff */
|
||||||
#include "brt.h"
|
#include "brt.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
#include "memory.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -96,6 +97,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
|
||||||
gettimeofday(&t3,0);
|
gettimeofday(&t3,0);
|
||||||
printf("Shutdown %.6fs\n", tdiff(&t3, &t2));
|
printf("Shutdown %.6fs\n", tdiff(&t3, &t2));
|
||||||
printf("Total time %.6fs for %lld insertions = %8.0f/s\n", tdiff(&t3, &t1), 2*total_n_items, 2*total_n_items/tdiff(&t3, &t1));
|
printf("Total time %.6fs for %lld insertions = %8.0f/s\n", tdiff(&t3, &t1), 2*total_n_items, 2*total_n_items/tdiff(&t3, &t1));
|
||||||
|
malloc_report();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,9 +134,14 @@ void *toku_calloc(long nmemb, long size) {
|
||||||
//if ((long)r==0x80523f8) { printf("%s:%d %p\n", __FILE__, __LINE__, r); }
|
//if ((long)r==0x80523f8) { printf("%s:%d %p\n", __FILE__, __LINE__, r); }
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
#define MALLOC_SIZE_COUNTING_LIMIT 256
|
||||||
|
int malloc_counts[MALLOC_SIZE_COUNTING_LIMIT];
|
||||||
|
int other_malloc_count=0;
|
||||||
void *toku_malloc(long size) {
|
void *toku_malloc(long size) {
|
||||||
void * r;
|
void * r;
|
||||||
errno=0;
|
errno=0;
|
||||||
|
if (size<MALLOC_SIZE_COUNTING_LIMIT) malloc_counts[size]++;
|
||||||
|
else other_malloc_count++;
|
||||||
r=actual_malloc(size);
|
r=actual_malloc(size);
|
||||||
//printf("%s:%d malloc(%ld)->%p\n", __FILE__, __LINE__, size,r);
|
//printf("%s:%d malloc(%ld)->%p\n", __FILE__, __LINE__, size,r);
|
||||||
note_did_malloc(r, size);
|
note_did_malloc(r, size);
|
||||||
|
@ -192,3 +197,12 @@ void print_malloced_items (void) {
|
||||||
printf(" %p size=%ld\n", items[i], sizes[i]);
|
printf(" %p size=%ld\n", items[i], sizes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void malloc_report (void) {
|
||||||
|
int i;
|
||||||
|
printf("malloc report:\n");
|
||||||
|
for (i=0; i<MALLOC_SIZE_COUNTING_LIMIT; i++) {
|
||||||
|
if (malloc_counts[i]) printf("%d: %d\n", i, malloc_counts[i]);
|
||||||
|
}
|
||||||
|
printf("Other: %d\n", other_malloc_count);
|
||||||
|
}
|
||||||
|
|
|
@ -22,3 +22,4 @@ extern int memory_check; // Set to nonzero to get a (much) slower version of mal
|
||||||
|
|
||||||
int get_n_items_malloced(void);
|
int get_n_items_malloced(void);
|
||||||
void print_malloced_items(void);
|
void print_malloced_items(void);
|
||||||
|
void malloc_report (void);
|
||||||
|
|
Loading…
Add table
Reference in a new issue