While writing some karma tests today for github.com/soroushjp/humble, I noticed something really strange. Sometimes the tests would take a long time to run (3-10s) and sometimes they would run in less than a second. After some experimentation I figured out how to consistently reproduce the results.
Watch this screen recording: http://recordit.co/R30bQ3ZowE. I have three different browsers open and connected to Karma (Chrome, Safari, Firefox). When the browser windows are visible, the tests run in under a second. When I cover up the browser windows with another window, the tests take much much longer. Safari even disconnects because it was taking too long. I was really skeptical at first, but I repeated the test many times and always got the same results.
Am I right about my educated guess on what's happening? Does OS X allocate more resources to windows that are visible?
FWIW this is on OS X 10.10.3, and I'm running the latest version of all browsers shown.
It is part of their battery saving stuff.