elgo2006
elgo2006

Reputation: 53

C++ Endless Loop Bottleneck?

I plan on writing a program where I take a number and compare it to a mathematical theorem to test if it's true or false, and then add one to the number to test the next number. Assume I do this in a massive loop where the loop ends if int == 100,000,000.

Is there any default bottleneck that's going to be in the .exe after it's compiled, or will this push my processor to max load until it completes the loop?

Thanks in advance.

Upvotes: 0

Views: 141

Answers (2)

Peter G.
Peter G.

Reputation: 15114

If you don't exhaust the available RAM which would cause swapping and an IO bottleneck, your program should be CPU bound.

One CPU core will be almost 100 % busy and if you use multiple threads or processes you can keep the whole CPU almost 100 % busy. I'm saying almost because most likely your operating system will have to do some housekeeping for a tiny fraction of the available time.

Upvotes: 1

TobiasR.
TobiasR.

Reputation: 801

As long as you dont use multithreading, it should be difficult to push your processor to max load. More loops only take more time, not more CPU load.

Upvotes: 1

Related Questions