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:
committed by
Facebook Github Bot
parent
26266bc607
commit
500007ccca
@@ -6,8 +6,6 @@
|
||||
*/
|
||||
|
||||
import {transform} from '@babel/core';
|
||||
import generate from '@babel/generator';
|
||||
|
||||
import electronStubs from '../electron-stubs';
|
||||
|
||||
const babelOptions = {
|
||||
@@ -23,14 +21,3 @@ test('transform electron requires to inlined stubs', () => {
|
||||
expect(body.type).toBe('ExpressionStatement');
|
||||
expect(body.expression.properties.map(p => p.key.name)).toContain('remote');
|
||||
});
|
||||
|
||||
test('transform performance calls to requires', () => {
|
||||
for (const method of ['mark', 'measure']) {
|
||||
const src = `performance.${method}('something')`;
|
||||
const transformed = transform(src, babelOptions).ast;
|
||||
const {code} = generate(transformed);
|
||||
expect(code).toBe(
|
||||
`require('perf_hooks').performance.${method}('something');`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user