admin管理员组文章数量:1414628
Just a noob question.
I run the following code on visual studio release mode. And is finishing almost immidiatelly meaning running through long long largeNumber = 9223372036854775807 increasments at so little time.
So how that is possible?
#include <iostream>
using namespace std;
int main()
{
std::cout << "Hello World!\n";
int ok;
cin >> ok;
cout << "starting\n";
long long i=1;
while (i > 0) {
++i;
}
--i;
cout <<"last:" << i << "\n";
}
i was expecting that will take some seconds at least. I though that a processor lets say 3.40 GHz simply mean that can make up to 3.4 billion actions on a second.!
PS.in java seems to go as slow as i was expecting.
public class NewClass1 {
public static void main(String[] args) {
long ts=System.currentTimeMillis();
long i=1;
while(i>0){
++i;
}
long te =System.currentTimeMillis();
--i;
System.out.println("last: "+i +" in millis:"+(te-ts));
}
}```
本文标签: performancewhy c run a while(long longgt0) in just under a second on CPU 340GHzStack Overflow
版权声明:本文标题:performance - why c++ run a while(long long>0) in just under a second? on CPU 3.40GHz - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745156679a2645214.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论