ImageVerifierCode 换一换
格式:DOCX , 页数:9 ,大小:16.39KB ,
资源ID:14730053      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/14730053.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(普通变量与寄存器变量速度对比文档格式.docx)为本站会员(b****2)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

普通变量与寄存器变量速度对比文档格式.docx

1、对于C程序,寄存器变量是不能取址的:几种线程本地存储变量和普通变量的性能比较God一直致力于研究高并发服务端的开发,这次要优化的是libGod库中的线程本地存储变量,线程本地存储变量访问非常频繁,优化后库的性能应该会提高不少。已知的线程本地存储方法有boost中的thread_specific_ptr类,gcc中的_thread关键字,pthread中的pthread_getspecific函数。这次测试这3中本地存储以及普通变量之间的性能差别,代码如下:#include iostream#include stdio.h#include pthread.h#include boost/thre

2、ad/thread.hpp#include boost/thread/tss.hppusing namespace std;class C public:C(int a) m_a = a;printf(“C() %dn”, m_a);C() printf(“C() %dn”, m_a);private:int m_a;#define TM 3#if TM = 1boost:thread_specific_ptrC pc;const char *testType = “boost”;#elif TM = 2_thread C *pc;const char *testType = “_thread

3、”;#elif TM = 3pthread_key_t pc;const char *testType = “pthread”;#elseC *pc;const char *testType = “normal”;#endifvoid boostthreadFunc() pc.reset(new C(10);pc = new C(20);if (pthread_key_create(cout “pthread_key_create” endl;return;if (pthread_setspecific(pc, new C(30) cout “pthread_setspecific” endl

4、;int switches = 5000000;int i = switches;struct timeval tm_start, tm_end;getTImeofday(while (i-) C *c1 = pc.get();C *c2 = pc.get();C *c3 = pc.get();C *c4 = pc.get();C *c5 = pc.get();C *c6 = pc.get();C *c7 = pc.get();C *c8 = pc.get();C *c9 = pc.get();C *c10 = pc.get();C *c11 = pc.get();C *c12 = pc.ge

5、t();C *c13 = pc.get();C *c14 = pc.get();C *c15 = pc.get();C *c16 = pc.get();C *c17 = pc.get();C *c18 = pc.get();C *c19 = pc.get();C *c20 = pc.get();C *c21 = pc.get();C *c22 = pc.get();C *c23 = pc.get();C *c24 = pc.get();C *c25 = pc.get();C *c26 = pc.get();C *c27 = pc.get();C *c28 = pc.get();C *c29 =

6、 pc.get();C *c30 = pc.get();C *c31 = pc.get();C *c32 = pc.get();C *c33 = pc.get();C *c34 = pc.get();C *c35 = pc.get();C *c36 = pc.get();C *c37 = pc.get();C *c38 = pc.get();C *c39 = pc.get();C *c40 = pc.get();C *c1 = pc;C *c2 = pc;C *c3 = pc;C *c4 = pc;C *c5 = pc;C *c6 = pc;C *c7 = pc;C *c8 = pc;C *c

7、9 = pc;C *c10 = pc;C *c11 = pc;C *c12 = pc;C *c13 = pc;C *c14 = pc;C *c15 = pc;C *c16 = pc;C *c17 = pc;C *c18 = pc;C *c19 = pc;C *c20 = pc;C *c21 = pc;C *c22 = pc;C *c23 = pc;C *c24 = pc;C *c25 = pc;C *c26 = pc;C *c27 = pc;C *c28 = pc;C *c29 = pc;C *c30 = pc;C *c31 = pc;C *c32 = pc;C *c33 = pc;C *c3

8、4 = pc;C *c35 = pc;C *c36 = pc;C *c37 = pc;C *c38 = pc;C *c39 = pc;C *c40 = pc;C *c1 = (C *)pthread_getspecific(pc);C *c2 = (C *)pthread_getspecific(pc);C *c3 = (C *)pthread_getspecific(pc);C *c4 = (C *)pthread_getspecific(pc);C *c5 = (C *)pthread_getspecific(pc);C *c6 = (C *)pthread_getspecific(pc)

9、;C *c7 = (C *)pthread_getspecific(pc);C *c8 = (C *)pthread_getspecific(pc);C *c9 = (C *)pthread_getspecific(pc);C *c10 = (C *)pthread_getspecific(pc);C *c11 = (C *)pthread_getspecific(pc);C *c12 = (C *)pthread_getspecific(pc);C *c13 = (C *)pthread_getspecific(pc);C *c14 = (C *)pthread_getspecific(pc

10、);C *c15 = (C *)pthread_getspecific(pc);C *c16 = (C *)pthread_getspecific(pc);C *c17 = (C *)pthread_getspecific(pc);C *c18 = (C *)pthread_getspecific(pc);C *c19 = (C *)pthread_getspecific(pc);C *c20 = (C *)pthread_getspecific(pc);C *c21 = (C *)pthread_getspecific(pc);C *c22 = (C *)pthread_getspecifi

11、c(pc);C *c23 = (C *)pthread_getspecific(pc);C *c24 = (C *)pthread_getspecific(pc);C *c25 = (C *)pthread_getspecific(pc);C *c26 = (C *)pthread_getspecific(pc);C *c27 = (C *)pthread_getspecific(pc);C *c28 = (C *)pthread_getspecific(pc);C *c29 = (C *)pthread_getspecific(pc);C *c30 = (C *)pthread_getspe

12、cific(pc);C *c31 = (C *)pthread_getspecific(pc);C *c32 = (C *)pthread_getspecific(pc);C *c33 = (C *)pthread_getspecific(pc);C *c34 = (C *)pthread_getspecific(pc);C *c35 = (C *)pthread_getspecific(pc);C *c36 = (C *)pthread_getspecific(pc);C *c37 = (C *)pthread_getspecific(pc);C *c38 = (C *)pthread_getspecific(pc);C *c39 = (C *)pthread_getspecific(pc);C *c40 = (C *)pthread_getspecific(pc);C

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1