You could guesstimate a second with:
Code:
looptime = time()
while time() < looptime+1000
{ i = i + 1
}
Then note what i was (let's call it i_max), and reuse it as:
Code:
while i < i_max+1 // to preserve the time used by that operation
{ i = i + 1
}