MacOS – My IDE runs tests slower when in a different workspace

javamacosspaces

I am developing a server-side application using Java and OSX and quite often I have to run a rather large test suite to make sure everything is alright. I am using IntelliJ IDEA (Java-based IDE).

When I use one workspace only, tests finish in about ~3 minutes no matter whether the IDE has focus or not. It just has to be in the same workspace.

When I move the IDE to a different workspace (so I'd have 2 workspaces) or into fullscreen mode (which essentially creates a new workspace), test execution is ~100% slower (takes about 6 minutes).

When I keep the focus in the second workspace for the whole execution time period, we're back to ~3 minutes.

This is really puzzling to me. I measured it using various number of workspaces and various number of applications per workspace, same results.


Clarification from the discussion from the comments, to avoid confusion:

If the focus in in the workspace with the IDE or full-screen IDE, it's fast. Once the focus is on a different workspace (so the IDE is either on a different workspace or in a full-screen mode (but with no focus)) then it is slower.

Best Answer

It part of OS X itself to optimize the resources and to keep wise balance between foreground process and background tasks. Operating system devotes more resources to the active workspace, and to put less CPU processing capacity to the background tasks.

Benefits are obvious:

  • the higher responsiveness for user of the system in the overall for the foreground process;
  • and less CPU load (less heat is produced, CPU fan is quiet), lower impact on the battery life.

It should be clearly visible with Activity Monitor App, how much power system devotes to specific process.