




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.:.;一个测试ACE各种内存分配战略效率的程序64位平台C/C+开发本卷须知在/en/l/上例出了28个在64位平台上运用C/C+开发的本卷须知,对于进入64位时代的程序员应该去看看这28个事项,这些英文读物对于有C/C+功底的朋友读起来应该并不难,我估计大约20-30分钟可以精读完一篇或者更快,下面是这28个本卷须知的列表。置信对大家一点有协助 。Bhui2021 HYPERLINK 61690 61690 Lesson 01. What 64-bit systems are. Lesson 02. Stestmalloc loop 10000 use time 32.950000 ste
2、stcached loop 10000 use time 1.730000 stestmallocmmap loop 10000 use time 5.050000 stestmallocmmaplite loop 10000 use time 5.030000 stestmalloclocal loop 10000 use time 0.620000 stestmalloclocalmutex loop 10000 use time 4.250000 stestmalloc_brk_mutex loop 10000 use time 0.600000 stestmallocsharemute
3、x loop 10000 use time 4.360000 s#include ace/OS_NS_stdio.h #include ace/OS_NS_string.h #include ace/Malloc_T.h #include ace/Null_Mutex.h #include time.h #include assert.h clock_t _begin;clock_t _end;int _loop;#define BEGIN(n) _begin = clock(); for (_loop = 0; _loop _loop+) #define END(s) _end = cloc
4、k(); printf( %s loop %d use time %lf s , s, _loop , (double)(_end - _begin) / (double)CLOCKS_PER_SEC); const int MAXSIZE = 1024;void *p1000;void testmalloc() int i = 0; for (i = 0; i 1000; i+) pi = malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) free(pi); typedef char BLOCKMAXSIZE;typed
5、ef ACE_Dynamic_Cached_Allocator ACE_SYNCH_NULL_MUTEX Allocator;Allocator cache(1000, MAXSIZE);void testcached() int i = 0; for (i = 0; i 1000; i+) pi = cache.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) cache.free(pi); typedef ACE_Malloc ACE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_m
6、map;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_NULL_MUTEX malloc_local;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_local_mutex;typedef ACE_Malloc ACE_SHARED_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_share_mutex;typedef ACE_Malloc ACE_SBRK_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_s
7、brk_mutex;typedef ACE_Malloc ACE_LITE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap_lite;template class T void testmalloc(T ml) int i = 0; for (i = 0; i 1000; i+) pi = ml.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) ml.free(pi); pi = NULL; int main(int argc,char* argv) BEGIN(10000) t
8、estmalloc(); END( testmalloc ) BEGIN(10000) testcached(); END( testcached ) ACE_MMAP_Memory_Pool_Options options(ACE_DEFAULT_BASE_ADDR, ACE_MMAP_Memory_Pool_Options:ALWAYS_FIXED, 1024 * 10000 ); malloc_mmap mm( hello , hello , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(1
9、0000) testmalloc(mm); END( testmallocmmap ) mm.remove(); malloc_mmap_lite mml( helloq , helloq , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mml); END( testmallocmmaplite ) mml.remove(); malloc_local ml( hello1 /fprintf(stderr, %d chuncks , ml.avail_chun
10、ks(MAXSIZE); BEGIN(10000) testmalloc(ml); END( testmalloclocal ) ml.remove(); malloc_local_mutex mlm( hello2 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlm); END( testmalloclocalmutex ) mlm.remove(); malloc_local mlb( hellob /fprintf(stderr, %d chuncks , ml.avail
11、_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlb); END( testmalloc_brk_mutex ) mlb.remove(); ACE_Shared_Memory_Pool_Options options2(ACE_DEFAULT_BASE_ADDR, 1, ACE_DEFAULT_FILE_PERMS, 1, 1024 * 1200 ); malloc_share_mutex msm( hello3 , hello3 , options2); BEGIN(10000) testmalloc(msm); END( testmallocshar
12、emutex ) msm.remove(); return 0;:/blog/cns!F66D6083FD44CD13!183.entrytestmalloc loop 10000 use time 32.950000 stestcached loop 10000 use time 1.730000 stestmallocmmap loop 10000 use time 5.050000 stestmallocmmaplite loop 10000 use time 5.030000 stestmalloclocal loop 10000 use time 0.620000 stestmall
13、oclocalmutex loop 10000 use time 4.250000 stestmalloc_brk_mutex loop 10000 use time 0.600000 stestmallocsharemutex loop 10000 use time 4.360000 s#include ace/OS_NS_stdio.h #include ace/OS_NS_string.h #include ace/Malloc_T.h #include ace/Null_Mutex.h #include time.h #include assert.h clock_t _begin;c
14、lock_t _end;int _loop;#define BEGIN(n) _begin = clock(); for (_loop = 0; _loop _loop+) #define END(s) _end = clock(); printf( %s loop %d use time %lf s , s, _loop , (double)(_end - _begin) / (double)CLOCKS_PER_SEC); const int MAXSIZE = 1024;void *p1000;void testmalloc() int i = 0; for (i = 0; i 1000
15、; i+) pi = malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) free(pi); typedef char BLOCKMAXSIZE;typedef ACE_Dynamic_Cached_Allocator ACE_SYNCH_NULL_MUTEX Allocator;Allocator cache(1000, MAXSIZE);void testcached() int i = 0; for (i = 0; i 1000; i+) pi = cache.malloc(MAXSIZE); assert(pi !=
16、 NULL); for (i = 0; i 1000; i+) cache.free(pi); typedef ACE_Malloc ACE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_NULL_MUTEX malloc_local;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_local_mutex;typedef ACE_Malloc ACE_SHARED_
17、MEMORY_POOL, ACE_SYNCH_MUTEX malloc_share_mutex;typedef ACE_Malloc ACE_SBRK_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_sbrk_mutex;typedef ACE_Malloc ACE_LITE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap_lite;template class T void testmalloc(T ml) int i = 0; for (i = 0; i 1000; i+) pi = ml.malloc(MAXSIZE);
18、 assert(pi != NULL); for (i = 0; i 1000; i+) ml.free(pi); pi = NULL; int main(int argc,char* argv) BEGIN(10000) testmalloc(); END( testmalloc ) BEGIN(10000) testcached(); END( testcached ) ACE_MMAP_Memory_Pool_Options options(ACE_DEFAULT_BASE_ADDR, ACE_MMAP_Memory_Pool_Options:ALWAYS_FIXED, 1024 * 1
19、0000 ); malloc_mmap mm( hello , hello , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mm); END( testmallocmmap ) mm.remove(); malloc_mmap_lite mml( helloq , helloq , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(
20、mml); END( testmallocmmaplite ) mml.remove(); malloc_local ml( hello1 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(ml); END( testmalloclocal ) ml.remove(); malloc_local_mutex mlm( hello2 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmallo
21、c(mlm); END( testmalloclocalmutex ) mlm.remove(); malloc_local mlb( hellob /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlb); END( testmalloc_brk_mutex ) mlb.remove(); ACE_Shared_Memory_Pool_Options options2(ACE_DEFAULT_BASE_ADDR, 1, ACE_DEFAULT_FILE_PERMS, 1, 1024
22、 * 1200 ); malloc_share_mutex msm( hello3 , hello3 , options2); BEGIN(10000) testmalloc(msm); END( testmallocsharemutex ) msm.remove(); return 0;:/blog/cns!F66D6083FD44CD13!183.entrytestmalloc loop 10000 use time 32.950000 stestcached loop 10000 use time 1.730000 stestmallocmmap loop 10000 use time
23、5.050000 stestmallocmmaplite loop 10000 use time 5.030000 stestmalloclocal loop 10000 use time 0.620000 stestmalloclocalmutex loop 10000 use time 4.250000 stestmalloc_brk_mutex loop 10000 use time 0.600000 stestmallocsharemutex loop 10000 use time 4.360000 s#include ace/OS_NS_stdio.h #include ace/OS
24、_NS_string.h #include ace/Malloc_T.h #include ace/Null_Mutex.h #include time.h #include assert.h clock_t _begin;clock_t _end;int _loop;#define BEGIN(n) _begin = clock(); for (_loop = 0; _loop _loop+) #define END(s) _end = clock(); printf( %s loop %d use time %lf s , s, _loop , (double)(_end - _begin
25、) / (double)CLOCKS_PER_SEC); const int MAXSIZE = 1024;void *p1000;void testmalloc() int i = 0; for (i = 0; i 1000; i+) pi = malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) free(pi); typedef char BLOCKMAXSIZE;typedef ACE_Dynamic_Cached_Allocator ACE_SYNCH_NULL_MUTEX Allocator;Allocator c
26、ache(1000, MAXSIZE);void testcached() int i = 0; for (i = 0; i 1000; i+) pi = cache.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) cache.free(pi); typedef ACE_Malloc ACE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_NULL_MUTEX malloc_
27、local;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_local_mutex;typedef ACE_Malloc ACE_SHARED_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_share_mutex;typedef ACE_Malloc ACE_SBRK_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_sbrk_mutex;typedef ACE_Malloc ACE_LITE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX ma
28、lloc_mmap_lite;template class T void testmalloc(T ml) int i = 0; for (i = 0; i 1000; i+) pi = ml.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) ml.free(pi); pi = NULL; int main(int argc,char* argv) BEGIN(10000) testmalloc(); END( testmalloc ) BEGIN(10000) testcached(); END( testcached
29、) ACE_MMAP_Memory_Pool_Options options(ACE_DEFAULT_BASE_ADDR, ACE_MMAP_Memory_Pool_Options:ALWAYS_FIXED, 1024 * 10000 ); malloc_mmap mm( hello , hello , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mm); END( testmallocmmap ) mm.remove(); malloc_mmap_lite
30、mml( helloq , helloq , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mml); END( testmallocmmaplite ) mml.remove(); malloc_local ml( hello1 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(ml); END( testmalloclocal ) ml.remove
31、(); malloc_local_mutex mlm( hello2 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlm); END( testmalloclocalmutex ) mlm.remove(); malloc_local mlb( hellob /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlb); END( testmalloc_brk_mutex
32、) mlb.remove(); ACE_Shared_Memory_Pool_Options options2(ACE_DEFAULT_BASE_ADDR, 1, ACE_DEFAULT_FILE_PERMS, 1, 1024 * 1200 ); malloc_share_mutex msm( hello3 , hello3 , options2); BEGIN(10000) testmalloc(msm); END( testmallocsharemutex ) msm.remove(); return 0;:/blog/cns!F66D6083FD44CD13!183.entrytestm
33、alloc loop 10000 use time 32.950000 stestcached loop 10000 use time 1.730000 stestmallocmmap loop 10000 use time 5.050000 stestmallocmmaplite loop 10000 use time 5.030000 stestmalloclocal loop 10000 use time 0.620000 stestmalloclocalmutex loop 10000 use time 4.250000 stestmalloc_brk_mutex loop 10000
34、 use time 0.600000 stestmallocsharemutex loop 10000 use time 4.360000 s#include ace/OS_NS_stdio.h #include ace/OS_NS_string.h #include ace/Malloc_T.h #include ace/Null_Mutex.h #include time.h #include assert.h clock_t _begin;clock_t _end;int _loop;#define BEGIN(n) _begin = clock(); for (_loop = 0; _
35、loop _loop+) #define END(s) _end = clock(); printf( %s loop %d use time %lf s , s, _loop , (double)(_end - _begin) / (double)CLOCKS_PER_SEC); const int MAXSIZE = 1024;void *p1000;void testmalloc() int i = 0; for (i = 0; i 1000; i+) pi = malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) fr
36、ee(pi); typedef char BLOCKMAXSIZE;typedef ACE_Dynamic_Cached_Allocator ACE_SYNCH_NULL_MUTEX Allocator;Allocator cache(1000, MAXSIZE);void testcached() int i = 0; for (i = 0; i 1000; i+) pi = cache.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) cache.free(pi); typedef ACE_Malloc ACE_MMA
37、P_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_NULL_MUTEX malloc_local;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_local_mutex;typedef ACE_Malloc ACE_SHARED_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_share_mutex;typedef ACE_Malloc ACE_SBR
38、K_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_sbrk_mutex;typedef ACE_Malloc ACE_LITE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap_lite;template class T void testmalloc(T ml) int i = 0; for (i = 0; i 1000; i+) pi = ml.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) ml.free(pi); pi = NULL; int m
39、ain(int argc,char* argv) BEGIN(10000) testmalloc(); END( testmalloc ) BEGIN(10000) testcached(); END( testcached ) ACE_MMAP_Memory_Pool_Options options(ACE_DEFAULT_BASE_ADDR, ACE_MMAP_Memory_Pool_Options:ALWAYS_FIXED, 1024 * 10000 ); malloc_mmap mm( hello , hello , options); /fprintf(stderr, %d chun
40、cks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mm); END( testmallocmmap ) mm.remove(); malloc_mmap_lite mml( helloq , helloq , options); /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mml); END( testmallocmmaplite ) mml.remove(); malloc_local ml( hello1 /fpr
41、intf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(ml); END( testmalloclocal ) ml.remove(); malloc_local_mutex mlm( hello2 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlm); END( testmalloclocalmutex ) mlm.remove(); malloc_local mlb( hellob
42、 /fprintf(stderr, %d chuncks , ml.avail_chunks(MAXSIZE); BEGIN(10000) testmalloc(mlb); END( testmalloc_brk_mutex ) mlb.remove(); ACE_Shared_Memory_Pool_Options options2(ACE_DEFAULT_BASE_ADDR, 1, ACE_DEFAULT_FILE_PERMS, 1, 1024 * 1200 ); malloc_share_mutex msm( hello3 , hello3 , options2); BEGIN(1000
43、0) testmalloc(msm); END( testmallocsharemutex ) msm.remove(); return 0;:/blog/cns!F66D6083FD44CD13!183.entrytestmalloc loop 10000 use time 32.950000 stestcached loop 10000 use time 1.730000 stestmallocmmap loop 10000 use time 5.050000 stestmallocmmaplite loop 10000 use time 5.030000 stestmalloclocal
44、 loop 10000 use time 0.620000 stestmalloclocalmutex loop 10000 use time 4.250000 stestmalloc_brk_mutex loop 10000 use time 0.600000 stestmallocsharemutex loop 10000 use time 4.360000 s#include ace/OS_NS_stdio.h #include ace/OS_NS_string.h #include ace/Malloc_T.h #include ace/Null_Mutex.h #include ti
45、me.h #include assert.h clock_t _begin;clock_t _end;int _loop;#define BEGIN(n) _begin = clock(); for (_loop = 0; _loop _loop+) #define END(s) _end = clock(); printf( %s loop %d use time %lf s , s, _loop , (double)(_end - _begin) / (double)CLOCKS_PER_SEC); const int MAXSIZE = 1024;void *p1000;void tes
46、tmalloc() int i = 0; for (i = 0; i 1000; i+) pi = malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) free(pi); typedef char BLOCKMAXSIZE;typedef ACE_Dynamic_Cached_Allocator ACE_SYNCH_NULL_MUTEX Allocator;Allocator cache(1000, MAXSIZE);void testcached() int i = 0; for (i = 0; i 1000; i+) p
47、i = cache.malloc(MAXSIZE); assert(pi != NULL); for (i = 0; i 1000; i+) cache.free(pi); typedef ACE_Malloc ACE_MMAP_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_mmap;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_NULL_MUTEX malloc_local;typedef ACE_Malloc ACE_LOCAL_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_local_mutex;typedef ACE_Malloc ACE_SHARED_MEMORY_POOL, ACE_SYNCH_MUTEX malloc_share_mutex;typedef ACE_Malloc ACE_SBRK_MEMORY_POOL, ACE_SYNCH_M
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- MY银行供应链金融保理业务流程优化研究
- 全GFRP筋增强混凝土剪力墙抗震性能研究
- 故事力法则下乡村文旅景观规划设计研究-以浙江新昌县棠村村为例
- 环境安全健康之间关系
- 护理质量管理人员培训大纲
- 肺炎性心脏病护理
- 甲状腺结节健康教育及指导
- 在线教育社群运营策划方案
- 护理心脏骤停的急救与后续管理
- 结肠肿瘤科普
- 2022-2023学年北京市东城区高二(下)期末化学试卷(含解析)
- 防溺水老师培训课件
- 《植物生长与环境》课程标准(含课程思政)
- 铁路行车组织(高职)全套教学课件
- 注塑标准成型条件表电子表格模板
- 道闸系统施工方案
- 配置管理与漏洞修复
- 新版中国复发难治性急性髓系白血病诊疗指南
- 保洁巡查记录表
- 成事的时间管理
- 国开大学2023年01月22503《学前儿童健康教育活动指导》期末考试答案
评论
0/150
提交评论