Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-55944

Reduce sleeps as much as possible in unit tests

XMLWordPrintable

      PHPUnit makes lots of calls to sleep() to ensure that calls to time() return different numbers. This slows down testings considerably. There are 54 seconds worth of sleep() via 34 calls.

      There are complex cards to enable mocking of time() to resolve this issue on a more comprehensive basis.

      In all uses of sleep(), what is really desired is that one second has rolled forward.

      To reduce that, we wait for the second to roll over. So we now wait for the time() function to return a different answer. This will 1/2 the wait time on average. And worst case example it will be no worse than sleep(1).

      There are a number of sleep(2) places that are replaced and will be a performance win regardless.

            mr-russ Russell Smith (Inactive)
            mr-russ Russell Smith (Inactive)
            Rajesh Taneja Rajesh Taneja
            Dan Poltawski Dan Poltawski
            Jake Dallimore Jake Dallimore
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.