`
david.joe2005
  • 浏览: 3307 次
  • 性别: Icon_minigender_1
  • 来自: 南京
最近访客 更多访客>>
社区版块
存档分类
最新评论

测试boost multi_index库遇到的性能问题

    博客分类:
  • c++
阅读更多
项目中,需要对一大堆不断变化的数据,动态的更新和排序处理。
就想到用内存数据库。
比较了sqlite、h2、berkeley DB、fastdb、times ten、boost multi_index。

开始认为 速度上,应该是 boost multi_index > fastdb > berkeley DB > sqllite 和h2

实际上同一台机器,测试了 sqlite和boost multi_index,
100万条相同的简单数据分别插入
sqlite 是39微秒一条,boost multi_index 竟然要10毫秒,太让人意外了。怎么说sqlite有sql语句解析的开销,应该sqlite慢一些才合理。

这个结果然我百思不得其解,后来联系了boost开发组。
他们回信说,

I understand you're running your test program in debug mode.If so, invariant-checking mode and safe mode (enabledin your code by defining BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKINGand BOOST_MULTI_INDEX_ENABLE_SAFE_MODE), and in particularthe former, will greatly decrease performance. These aremeant to be used as debugging aids, not in productionmode. Please turn them off and recheck. Also, performanceshould be much better in release mode, both becauseit is release mode after all and because you're not definingthe aforementioned macros in that case.

他的意思是关掉2个宏,去掉安全模式和变量检查,速度就会快。
按他说的重新测试了一下,multi_index 速度为 22微秒一条。
这样的速度才对。

考虑到c++ stl 容器插入有变量拷贝的开销。
如果深度优化的话,极限速度在 10微秒左右,应该是可能的。

手头的应用,multi_index速度就足够。
顺便向大家推荐一下boost multi_index库,一个不错的便捷版本的内存数据库。

0
0
分享到:
评论
1 楼 xianglei 2010-01-11  
不知道对并发支持怎么样啊?

相关推荐

Global site tag (gtag.js) - Google Analytics