Just wondering what the fastest type of loop is, is it the while loop?
Thanks!
Fastest type of loop
Moderator: General Moderators
Re: Fastest type of loop
http://www.blueshoes.org/phpBench.phpGeXus wrote:Just wondering what the fastest type of loop is, is it the while loop?
Thanks!
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If in need of an ultrafast infinite loop, I always useThis is a carryover from my C days, but I believe it still stands as the fastest possible loop. Why? Because there's no checks or code to run for the language at any point other than that inside the loop. Granted, it is microscopic amounts of time difference usually, but when you're running very time critical code, you need really tight loops.
Code: Select all
for(;;)
{
// code here
}- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
It's been a very long time, but i think this looks more like the Pascal style 
Code: Select all
while true do
begin
statements;
end;