简体   繁体   English

最快的C ++地图,用于在实时应用程序中执行最坏情况的时间?

[英]Fastest C++ map for worst-case time execution in a real time app?

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. a)由时间值键入的某些时间的C ++映射甚至可行,当可能存在数千个条目时b)哪个映射或散列表实现将给出最佳性能,其中最佳表示最低最坏情况执行,而不是最低平均值。 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? c)对于现在共享相同的一堆事件,是否应该使用某种哈希多图或在给定时间链接所有事件的列表?

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 时间以它自己的格式编码,代表部分:bars:beats:ticks

thanks! 谢谢! iain 伊恩

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 and std::unordered_multimap , with time as the key. std::multimapstd::unordered_multimap开头,以时间为关键字。 Both should have pretty good performance. 两者都应该有相当不错的表现。 Try a few different allocators, too. 尝试一些不同的分配器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM