@@ -58,12 +58,21 @@ function prepareBenchmarkProjects(revisionList) {
58
58
path . join ( projectPath , 'package.json' ) ,
59
59
'{ "private": true }' ,
60
60
) ;
61
- exec (
62
- 'npm --quiet install --ignore-scripts ' + prepareNPMPackage ( revision ) ,
63
- { cwd : projectPath } ,
64
- ) ;
65
61
exec ( `cp -R ${ localDir ( 'benchmark' ) } ${ projectPath } ` ) ;
66
62
63
+ const packageJSON = {
64
+ private : true ,
65
+ type : 'module' ,
66
+ dependencies : {
67
+ graphql : prepareNPMPackage ( revision ) ,
68
+ } ,
69
+ } ;
70
+ fs . writeFileSync (
71
+ path . join ( projectPath , 'package.json' ) ,
72
+ JSON . stringify ( packageJSON , null , 2 ) ,
73
+ ) ;
74
+ exec ( 'npm --quiet install --ignore-scripts ' , { cwd : projectPath } ) ;
75
+
67
76
return { revision, projectPath } ;
68
77
} ) ;
69
78
@@ -334,21 +343,21 @@ function grey(str) {
334
343
335
344
function sampleModule ( modulePath ) {
336
345
const sampleCode = `
337
- const assert = require('assert');
338
-
346
+ import assert from 'assert';
339
347
assert(global.gc);
340
348
assert(process.send);
341
- const module = require('${ modulePath } ');
342
349
343
- clock(7, module.measure); // warm up
350
+ import { benchmark } from '${ modulePath } ';
351
+
352
+ clock(7, benchmark.measure); // warm up
344
353
global.gc();
345
354
process.nextTick(() => {
346
355
const memBaseline = process.memoryUsage().heapUsed;
347
- const clocked = clock(module .count, module .measure);
356
+ const clocked = clock(benchmark .count, benchmark .measure);
348
357
process.send({
349
- name: module .name,
350
- clocked: clocked / module .count,
351
- memUsed: (process.memoryUsage().heapUsed - memBaseline) / module .count,
358
+ name: benchmark .name,
359
+ clocked: clocked / benchmark .count,
360
+ memUsed: (process.memoryUsage().heapUsed - memBaseline) / benchmark .count,
352
361
});
353
362
});
354
363
@@ -369,6 +378,7 @@ function sampleModule(modulePath) {
369
378
'--no-concurrent-sweeping' ,
370
379
'--predictable' ,
371
380
'--expose-gc' ,
381
+ '--input-type=module' ,
372
382
'--eval' ,
373
383
sampleCode ,
374
384
] ,
0 commit comments