tcmalloc简单测试
来源:互联网 发布:法国文化史知乎 编辑:程序博客网 时间:2024/05/17 22:26
测试方式如下:
20个线程同时进行malloc和free的操作,每个线程进行malloc和free的操作1M次,每次申请的大小是操作次数的大小(比如第10次操作,就malloc(10))。
测试每个线程操作1M次malloc和free的时间。
glibc malloc的结果如下:
time use 20118516 secondtime use 20159695 secondtime use 20209392 secondtime use 20243706 secondtime use 20314329 secondtime use 20409412 secondtime use 20497020 secondtime use 20485955 secondtime use 20536799 secondtime use 20530233 secondtime use 20615596 secondtime use 20697397 secondtime use 20783369 secondtime use 20798414 secondtime use 20832314 secondtime use 20844732 secondtime use 20847341 secondtime use 20877054 secondtime use 20919291 secondtime use 20924166 second
tcmalloc的结果如下:
time use 6547655 secondtime use 6586277 secondtime use 6595014 secondtime use 6602379 secondtime use 6603297 secondtime use 6617556 secondtime use 6606473 secondtime use 6594718 secondtime use 6625851 secondtime use 6610081 secondtime use 6627009 secondtime use 6632563 secondtime use 6632408 secondtime use 6614826 secondtime use 6616527 secondtime use 6639291 secondtime use 6640707 secondtime use 6641525 secondtime use 6616567 secondtime use 6643258 second
代码如下:
#include <stdio.h>#include <stdint.h>#include <stdlib.h>#include <time.h>#include <pthread.h>#define LOOP_NUM (1024 * 1024)#define THREAD_NUM 20static void *fun_thread(void *argv){struct timeval start, end;gettimeofday(&start, NULL);uint32_t i;for(i = 0; i < LOOP_NUM; i++) {uint8_t *a = malloc(i);free(a);}gettimeofday(&end, NULL);printf("time use %ld second\n", (end.tv_sec - start.tv_sec) * 1000000 + end.tv_usec - start.tv_usec);return NULL;}void main(void){pthread_t a[THREAD_NUM];uint8_t i;for(i = 0; i < THREAD_NUM; i++) pthread_create(&a[i], NULL, fun_thread, NULL);for(i = 0; i < THREAD_NUM; i++) pthread_join(a[i], NULL);}
编译如下:
@gcc $< -o $@ -lpthread@gcc $< -o $@ -lpthread -ltcmalloc_minimal
0 0
- tcmalloc简单测试
- win32测试Tcmalloc性能
- tcmalloc简单分析
- TCMalloc
- TCMalloc
- TCMalloc
- TCMalloc
- TCMalloc
- TCMalloc
- tcmalloc
- tcmalloc
- Tcmalloc
- 顺便测试了一下google的tcmalloc.
- glibc内存泄露以及TCmalloc 简单分析
- MySQL测试 5.1 innodb VS innodb_plugin VS innodb_plugin+tcmalloc VS 5.5+tcmalloc
- GooglePerformanceTools--tcmalloc
- tcmalloc 要点
- 关于tcmalloc
- 为什么区块链技术对许多行业都有吸引力?
- UVA-10285 Longest Run on a Snowboard
- 51nod 1624 STL妙用+二分
- mysql 左连接 右连接
- getHibernateTemplate().find方法详解
- tcmalloc简单测试
- untiy 物体随着鼠标的移动而移动的脚本:
- EGE 在Dev下的环境配置 和 第一个绘图程序
- 安卓chrome前端网页调试
- system获取系统属性
- EventBus的详细解析
- 让监管者了解区块链是头等大事
- split_explode_strcmp.php
- UIScrollView的属性总结