@@ -58,12 +58,21 @@ function prepareBenchmarkProjects(revisionList) {
5858 path . join ( projectPath , 'package.json' ) ,
5959 '{ "private": true }' ,
6060 ) ;
61- exec (
62- 'npm --quiet install --ignore-scripts ' + prepareNPMPackage ( revision ) ,
63- { cwd : projectPath } ,
64- ) ;
6561 exec ( `cp -R ${ localDir ( 'benchmark' ) } ${ projectPath } ` ) ;
6662
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+
6776 return { revision, projectPath } ;
6877 } ) ;
6978
@@ -334,21 +343,21 @@ function grey(str) {
334343
335344function sampleModule ( modulePath ) {
336345 const sampleCode = `
337- const assert = require('assert');
338-
346+ import assert from 'assert';
339347 assert(global.gc);
340348 assert(process.send);
341- const module = require('${ modulePath } ');
342349
343- clock(7, module.measure); // warm up
350+ import { benchmark } from '${ modulePath } ';
351+
352+ clock(7, benchmark.measure); // warm up
344353 global.gc();
345354 process.nextTick(() => {
346355 const memBaseline = process.memoryUsage().heapUsed;
347- const clocked = clock(module .count, module .measure);
356+ const clocked = clock(benchmark .count, benchmark .measure);
348357 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,
352361 });
353362 });
354363
@@ -369,6 +378,7 @@ function sampleModule(modulePath) {
369378 '--no-concurrent-sweeping' ,
370379 '--predictable' ,
371380 '--expose-gc' ,
381+ '--input-type=module' ,
372382 '--eval' ,
373383 sampleCode ,
374384 ] ,
0 commit comments