minkphp / MinkSelenium2Driver

Selenium2 (webdriver) driver for Mink framework
MIT License
507 stars 163 forks source link

only sleep in wait() if the result is not true #270

Closed individual-it closed 6 years ago

individual-it commented 7 years ago

there is no need to sleep if the result is already true, so save some time

aik099 commented 7 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).

stof commented 7 years ago

@aik099 if the result is true, the loop will exit

aik099 commented 7 years ago

@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.

individual-it commented 7 years ago

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

-

aik099 commented 7 years ago

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).

individual-it commented 7 years ago

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

individual-it commented 7 years ago

sorry $result need to be set of course