Don't used defined(window) because window is not declared.

In fact, avoid `window` entirely and just check for the existence of a global `performance` property.

I didn't find any other cases where we did something similar.

This fixes issue #1457.