macport google-perftools @1.7 (devel)を試す2011/04/21 03:14

macportsに
google-perftools @1.7 (devel)
Fast, multi-threaded malloc() and nifty performance analysis tools
 があったので

拾ってきたテスト プログラム
#----- test program start
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char** argv)
{
int i,j;
for (i = 0; i < 100; i++) {
for (j = 0; j < 1000; j++) {
char *p = (char *) malloc (1024 * 1024);
free (p);
}
}
return 0;
}
#---- test program end

テスト プログラムをコンパイル、linkして実行
$ time ./a.out

real 0m0.090s
user 0m0.049s
sys 0m0.023s
テスト プログラム -ltcmallocを付けてコンパイル、link
$ gcc test.c -ltcmalloc
$ time ./a.out

real 0m0.041s
user 0m0.018s
sys 0m0.006s

作業はmacbookAirで実行