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会员
最新内容
《深度强化学习在兵棋推演中的应用》40页报告
专知会员服务
4+阅读 · 今天5:37
《多域作战面临复杂现实》
专知会员服务
3+阅读 · 今天5:35
《印度的多域作战:条令与能力发展》报告
专知会员服务
2+阅读 · 今天5:24
人工智能赋能无人机:俄乌战争(万字长文)
专知会员服务
6+阅读 · 4月23日
国外海军作战管理系统与作战训练系统
专知会员服务
3+阅读 · 4月23日
美军条令《海军陆战队规划流程(2026版)》
专知会员服务
10+阅读 · 4月23日
《压缩式分布式交互仿真标准》120页
专知会员服务
4+阅读 · 4月23日
《电子战数据交换模型研究报告》
专知会员服务
6+阅读 · 4月23日
相关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会员