Closed individual-it closed 6 years ago
This might actually be anti-optimization, because time to check condition in IF statement (on each iteration) you've added might be greater than sleep time you're trying to avoid (once).
@aik099 if the result is true
, the loop will exit
@aik099 if the result is true, the loop will exit
That is how it works currently. But what I'm saying that extra code to check same exit condition only doubles code run time which is spending more time then is saved by calling usleep
extra time after $result is true.
So you suggesting the if statement will take longer than 1/10s
On May 30, 2017 2:02:48 PM GMT+05:45, Alexander Obuhovich notifications@github.com wrote:
@aik099 if the result is true, the loop will exit
That is how it works currently. But what I'm saying that extra code to check same exit condition only doubles code run time which is spending more time then is saved by calling
usleep
extra time after $result is true.-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/minkphp/MinkSelenium2Driver/pull/270#issuecomment-304807654
-
It depends on how soon condition will become true. If element doesn't appear on the page for certain amount of time, then total time spent on that extra IF execution might be close (I haven't measured really) to sleep time.
I think you'd better attach some benchmarks for cases with extra IF and without it with different waiting times (e.g. element appeared after X milliseconds, sleep time, extra if time, total time).
What about changing it around and having a while and not a do...while loop? Then there are the same amount of checks, but the loop only waits if the condition is not true. If the condition returns "true" strait away we save 1/10s
sorry $result need to be set of course
there is no need to sleep if the result is already true, so save some time