Using consteval from C++23, we implement efficient, new versions of std::map and std::unordered_map for use when the keys are known at compile time. We demonstrate superior performance of our unordered_map on three demonstration use-cases: Lookup of elemental mass from atomic symbol, lookup of amino acid from codon, and modification of stock prices from S&P 500 ticker symbols all produced runtimes <40%, <35%, <73% of the respective runtimes of the std implementations. Our library runimes were <80%, <45%, <97% of the lookup time of Frozen, an alternative perfect hashing implementation in C++ for problems also using constexpr keys. To our knowledge, this makes our library the overall fastest drop-in (i.e., with a similar API) alternative to std::unordered_map. On one arbitrarily chosen demo, we demonstrate runtimes <35% of PTHash and <89% gperf, state-of-the-art but not drop-in hashing libraries via external tools.


翻译:利用 C++23 中的 consteval 特性,我们实现了高效的新版本 std::map 和 std::unordered_map,适用于键值在编译时已知的场景。我们在三个示例用例中展示了我们实现的 unordered_map 的优越性能:根据原子符号查找元素质量、根据密码子查找氨基酸、根据标普 500 股票代码修改股价,其运行时间分别低于标准库实现的 40%、35% 和 73%。与同样使用 constexpr 键值的 C++ 替代完美哈希实现 Frozen 相比,我们库的查找时间分别低于其 80%、45% 和 97%。据我们所知,这使得我们的库成为与 std::unordered_map API 相似的直接替代方案中整体最快的选择。在一个任意选取的演示案例中,我们展示了运行时间低于 PTHash 的 35% 和低于 gperf 的 89%,这两者是通过外部工具实现的最新但非直接替代的哈希库。

0
下载
关闭预览

相关内容

【Manning新书】C++并行实战,592页pdf,C++ Concurrency in Action
【2020新书】C++20 特性 第二版,A Problem-Solution Approach
专知会员服务
60+阅读 · 2020年4月26日
图机器学习 2.2-2.4 Properties of Networks, Random Graph
图与推荐
10+阅读 · 2020年3月28日
【泡泡图灵智库】体积实例感知语义建图与3D对象发现
泡泡机器人SLAM
22+阅读 · 2019年9月7日
图上的归纳表示学习
科技创新与创业
23+阅读 · 2017年11月9日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
Arxiv
0+阅读 · 3月17日
VIP会员
最新内容
世界模型入门:从序贯决策到通用智能体
专知会员服务
5+阅读 · 10月24日
军事域更好使用人工智能的实用指南
专知会员服务
9+阅读 · 10月22日
《衡量语言模型中的作战规划能力》
专知会员服务
14+阅读 · 10月20日
Maven智能系统:帕兰提尔军事人工智能平台详解
专知会员服务
16+阅读 · 10月20日
《测试自动化框架在敏捷软件开发中的角色》
专知会员服务
8+阅读 · 10月20日
俄罗斯如何拦截乌克兰无人机与巡航导弹
专知会员服务
12+阅读 · 10月15日
《武器-目标分配问题:精确与近似求解算法》
专知会员服务
18+阅读 · 10月15日
相关VIP内容
【Manning新书】C++并行实战,592页pdf,C++ Concurrency in Action
【2020新书】C++20 特性 第二版,A Problem-Solution Approach
专知会员服务
60+阅读 · 2020年4月26日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员