use perf_hooks

Summary:
We were using `window.performance` to measure performance. This was because the equivalent node.js API `perf_hooks` wasn't available in the electron version we were using back then.
However, `perf_hooks` has landed in electron meanwhile, so I am moving to this API, as it works for the headless version and jest tests, too.

This allows us to delete the babel transform that was used for node-based tests, where the browser API was replaced with the node API

Reviewed By: jknoxville

Differential Revision: D13860133

fbshipit-source-id: cf1395004fac046dd55751ff465af494173b2cbf
This commit is contained in:
Daniel Büchele
2019-01-29 09:26:21 -08:00
committed by Facebook Github Bot
parent 26266bc607
commit 500007ccca
7 changed files with 8 additions and 49 deletions

View File

@@ -11,7 +11,6 @@ var fs = require('fs');
var electronStubs = babylon.parseExpression(
fs.readFileSync('static/electron-stubs.notjs').toString(),
);
var perfHooks = babylon.parseExpression("require('perf_hooks').performance");
module.exports = function(babel) {
return {
@@ -28,17 +27,6 @@ module.exports = function(babel) {
path.replaceWith(electronStubs);
}
}
if (
path.node.type === 'CallExpression' &&
path.node.callee.type === 'MemberExpression' &&
path.node.callee.object.name === 'performance'
) {
// 'perf_hooks' was added in Node 8.5.0 but doesn't appear to be
// present in electron. We can remove this and switch to using
// interval when it is. Until then, continue using browser.performance
// for real and swap in node's perf_hooks when we dont have electron.
path.node.callee.object = perfHooks;
}
},
},
};