最快的 C++实时应用程序中最坏情况时间执行的映射?
我试图弄清楚如何在实时音频应用程序中存储定时事件,该应用程序可能会在时间上跳跃很多,并且需要以尽可能低的延迟运行。基本上,引擎知道“现在”是什么时间,但“现在”可能是非线性的,并且将来会有多个“现在”。我想知道:
a)当可能有数千个条目时,由时间值键控的某个时间的 C++ 地图是否可行 b) 哪种映射或哈希表实现将为我提供最佳性能,其中最佳意味着最低的最坏情况执行,而不是最低的平均值。即使偶尔需要很长时间的实现也将无法使用,具有更具确定性结果的实现会更好。 c) 对于现在共享相同内容的一堆事件,是否应该使用某种哈希多重映射或链接给定时间的所有事件的列表?
我也愿意接受任何其他有关如何执行此操作的建议或资源指针。时间以它自己的格式编码,代表部分:小节:节拍:滴答声,
谢谢! 伊恩
I'm trying to figure out how I want to store timed events in a real time audio app that may hop around in time a lot, and needs to run with the lowest latency possible. Basically the engine knows what time 'now' is, but 'now' may be non-linear, and there be multiple 'nows' in the future. I'm wondering if:
a) a C++ map of some time keyed by time values is even feasible, when there could be thousands of entries
b) which map or hash table implementation will give me the best performance where best means lowest worst case execution, not lowest average. An implementation that even once in a while takes a really long time will be unusable, something with a more deterministic result would be better.
c) for a bunch of events sharing the same now, should one use some sort of hash multi map or link a list of all events at a given time?
I'm open to any other suggestions of how to do this too, or pointers to resources. Time is encoded in it's own format, representing sections:bars:beats:ticks
thanks!
iain
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有什么可以让您不必分析您的代码并亲自查看。
使数据类型尽可能容易更改,保持所有内容模块化和参数化,然后运行一些测试。
从
std::multimap
和std::unordered_multimap
开始,以时间为关键。两者应该都有不错的表现。也尝试一些不同的分配器。Nothing can save you from having to profile your code and see for yourself.
Make the data type as easy to change as possible, keep everything modular and parameterised, and then just run some tests.
Start with
std::multimap
andstd::unordered_multimap
, with time as the key. Both should have pretty good performance. Try a few different allocators, too.