包括每个标头是否会对性能产生影响? [英] Are there any performance implications to including every header?
本文介绍了包括每个标头是否会对性能产生影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我想使用 hex()
函数.我知道它是在< ios>
标头中定义的,并且我也知道它包含在< iostream>
标头中.区别在于< iostream>
中有更多我不需要的功能和其他内容.
Lets say I want to use hex()
function. I know it is defined in <ios>
header and I also know that it is included in <iostream>
header. The difference is that in <iostream>
are much more functions and other stuff I don't need.
从性能的角度来看,我是否应该在乎包含/定义的函数,类等少于/多于?
From a performance stand-point, should I care about including/defining less functions, classes etc. than more?
推荐答案
- 运行时性能没有受到影响.
- 但是,如果包含大量不必要的标头,则可能会浪费过多的编译时间.
- 此外,完成此操作后,例如,如果更改了标头但不使用标头的文件包含标头,则可以创建不必要的重新编译.
在小型项目(包括小的标题)中,这无关紧要.随着项目的发展,它可能会发生.
In small projects (with small headers included), this doesn't matter. As a project grows, it may.
这篇关于包括每个标头是否会对性能产生影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文