Tom*_*hao -1 c++ performance iostream loops
例如..如果我有.
#include <iostream>
using namespace std;
int main()
{
int counter = 0;
while (true)
{
cout << counter << endl;
counter++
}
}
Run Code Online (Sandbox Code Playgroud)
并且说我在与其他计算机竞争10亿的竞争中,这个循环的运行速率纯粹取决于计算机处理器的速度?或者我的程序运行速度有限制,这可能是多变的?
摆脱endl并使用"\n"而不是.计划至少比单独加速4倍.
将输出写入文件而不是屏幕.这对于另外10倍的速度改进应该是好的(或者更好 - 如果你使用SSD则更多).
| 归档时间: |
|
| 查看次数: |
3189 次 |
| 最近记录: |