Skip to content

Commit 0568a8f

Browse files
committed
Integrate time-require into the CLI.
I want to start focusing on getting our require times down, both in the main thread and forked tests. This adds `time-require` support directly to the CLI to assist in that. This is especially important for forked test processes, where I currently have to manually add a line of code each time I want to test an optimization. I don't think this should be a publicly documented move. I think we want the freedom to remove this once we are happy with performance. I have placed comments above all `time-require` references, indicating it is for internal use only. Users have been given fair warning against relying on its inclusion long term. Usage: ```sh $ ./cli.js test/fixture/es2015.js --time-require --sorted ``` `--sorted` is optional. It sorts the requires from most expensive to least. The default is sequential sorting. The output will display multiple `time-require` reports. One for each forked process, and the last one for the main thread.
1 parent fa70351 commit 0568a8f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

cli.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/usr/bin/env node
22
'use strict';
3+
4+
// Intended for internal optimization tests only.
5+
var hasFlag = require('has-flag');
6+
if (hasFlag('time-require')) {
7+
require('time-require');
8+
}
9+
310
var fs = require('fs');
411
var path = require('path');
512
var figures = require('figures');
@@ -109,6 +116,14 @@ function run(file) {
109116
args.push('--serial');
110117
}
111118

119+
// Intended for internal optimization tests only.
120+
if (hasFlag('time-require')) {
121+
args.push('--time-require');
122+
if (hasFlag('sorted')) {
123+
args.push('--sorted');
124+
}
125+
}
126+
112127
return fork(args)
113128
.on('stats', stats)
114129
.on('test', test)

lib/babel.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
'use strict';
22

3+
// Intended for internal optimization tests only.
4+
var hasFlag = require('has-flag');
5+
if (hasFlag('time-require')) {
6+
require('time-require');
7+
}
8+
39
// Bind globals first, before anything has a chance to interfere.
410
var globals = require('./globals');
511

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"set-immediate-shim": "^1.0.1",
110110
"source-map-support": "^0.3.3",
111111
"squeak": "^1.2.0",
112+
"time-require": "^0.1.2",
112113
"update-notifier": "^0.5.0"
113114
},
114115
"devDependencies": {

0 commit comments

Comments
 (0)