简体   繁体   English

reverse_iterator 与迭代器的性能?

[英]Performances of reverse_iterator vs iterator?

I am designing a very efficient iterator for a High Performance Computing / Supercomputer application.我正在为高性能计算/超级计算机应用程序设计一个非常高效的迭代器。 I was wondering whether the std::reverse_iterator adaptor will introduce some overhead or whether it is likely to compile and achieve the exact same performances as the iterator type it is applied to.我想知道std::reverse_iterator适配器是否会引入一些开销,或者它是否可能编译并实现与其应用的迭代器类型完全相同的性能。

When it comes to performance, don't guess, don't ask, measure .说到性能,不要猜测,不要问,测量 And don't measure with artificial small test programs.并且不要用人工的小测试程序来衡量。 Measure speed with your real code, your real application, your real data on real target machines.使用真实代码、真实应用程序、真实目标机器上的真实数据测量速度。

C++ as a language does not make any guarantees as to whether std::reverse_iterator introduces overhead or not. C++ 作为一种语言不保证std::reverse_iterator是否引入开销。 The question would be a bit more answerable if you at least told us which compiler and which compiler options you are using, because the performance of standard-library facilities (algorithmic complexity requirements aside) is a quality-of-implementation (QoI) issue.如果您至少告诉我们您使用的是哪种编译器和哪些编译器选项,这个问题会更容易回答,因为标准库设施的性能(算法复杂性要求除外)是一个实现质量 (QoI) 问题。 It's unlikely that you would experience a difference in performance with std::reverse_iterator , but who knows?您不太可能在使用std::reverse_iterator遇到性能差异,但谁知道呢?

You also have not told us anything about the underlying iterator that you want to adapt.您也没有告诉我们您想要适应的底层迭代器的任何信息。 It may, for instance, be an iterator into a custom container and have different performance characteristics for -- and ++ .例如,它可能是自定义容器中的迭代器,并且对--++具有不同的性能特征。

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

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