boost::lockfree::queue记录
来源:互联网 发布:windows系统还原在哪 编辑:程序博客网 时间:2024/05/16 07:35
(1)pop的坑
boost::lockfree::queue<Point *> msgQueue;
若循环中如下调用
Point * pPoint = NULLmsgQueue.pop(pPoint);若pop返回值是false,一般按常理会认为pPoint是空值,但是实际测试中pPoint不是空值。所以不能以pPoint的值是否改变作为后续逻辑的判断条件。
(2)队列测试
测试环境1:
500个模拟客户端,消息发送量大概在8229.033个/秒左右
发送效率对比:
原有消息队列
12:54:10.309 5916 ACTION_ERROR: count:29000000, MaxTime:4.8850, avg:0.0125
新消息队列:
14:10:29.335 3272 ACTION_ERROR: count:29000000, MaxTime:2.7910, avg:0.0039
接受消息队列对比
原有消息队列
14:51:40.322 5600 ACTION_ERROR: Recv count:3290000, MaxTime:2.8870, avg:0.0015
新消息队列
14:40:27.211 4908 ACTION_ERROR: Recv count:3290000, MaxTime:2.3850, avg:0.0013
(2)测试环境2:
1250个模拟客户端,消息发送量大概在17796.066个/秒左右
发送效率对比:
原有消息队列
16:26:47.687 4196 ACTION_ERROR: Send count:4300000, MaxTime:24.2220, avg:0.0024
新消息队列
16:35:59.948 3552 ACTION_ERROR: Send count:4300000, MaxTime:27.2790, avg:0.0014
接受消息对比
原有消息队列
16:14:54.385 5684 ACTION_ERROR: Recv count:4900000, MaxTime:25.7500, avg:0.0009
新消息队列
16:05:45.348 5124 ACTION_ERROR: Recv count:4900000, MaxTime:35.9960, avg:0.0003
(3)结论
低负载的时候:
发送消息的效率大概是原有队列的3倍
接收消息的效率大概是原有队列的1.1倍
高负载的时候:
发送消息的效率大概是原有队列的1.58倍
接收消息的效率大概是原有队列的3倍
测试参考代码:
LARGE_INTEGER counterStart;QueryPerformanceCounter(&counterStart);/*此处可以换成发送*/if (!m_pNetMgrMsgPort->Recv(PORT_ANY, PACKET_ANY, STRUCT_TYPE(buf), buf,&cStatus)) {break;}LARGE_INTEGER counterEnd;QueryPerformanceCounter(&counterEnd);LARGE_INTEGER frequency;QueryPerformanceFrequency(&frequency);long lTime = (long)((counterEnd.QuadPart - counterStart.QuadPart) * 1000 / (double)frequency.QuadPart * 1000);static unsigned int unTotal = 0;static unsigned int i = 0;static long slTotalTime = 0.0;static long lMaxTime = 0.0;InterlockedIncrement(&i);InterlockedIncrement(&unTotal);InterlockedExchangeAdd(&slTotalTime, lTime);if (lTime > lMaxTime){lMaxTime = lTime;}if (i % 5000 == 0){static int j = 0;j++;LOG ("Recv count:%d, MaxTime:%4.4f, avg:%4.4f\n", unTotal, lMaxTime / 1000.0, slTotalTime / (double)i / 1000.0);// if (j >= 9)// {// lMaxTime = 0.0;// slTotalTime = 0;// j = 0;// i = 0;// }}
- boost::lockfree::queue记录
- Boost Lockfree
- Boost Lockfree
- Boost.Lockfree
- boost lockfree lib
- Boost.lockfree总结
- Boost之LockFree
- Boost.Lockfree官方文档翻译
- Boost.Lockfree官方文档翻译
- Boost.Lockfree官方文档翻译
- evpp性能测试(3): 对无锁队列boost::lockfree::queue和moodycamel::ConcurrentQueue做一个性能对比测试
- 带回收功能的lockfree queue的java实现
- boost 记录
- [LockFree之美] 使用Hazard Version实现的无锁Stack与Queue
- boost interprocess之message queue
- boost无锁队列queue
- boost学习记录
- boost常用记录
- IOS NSDateFormatter 自定义 格式
- DP-POJ-1661-Help Jimmy
- 原子操作的实现原理
- Android 测试类型
- linux基本命令三の管理进程
- boost::lockfree::queue记录
- 有关异常需要理解和注意的地方!!!
- 面试题2015
- Python下载及Python环境变量的配置
- Shell实现(三)读取命令的实现
- C++用链表存放数据
- Java Web 技术整合基础篇1 web产生及发展
- Git学习笔记
- 题目:排序矩阵中的从小到大第k个数