Skip to content

Commit a29bbbd

Browse files
committed
fix: addressing comment
1 parent e373623 commit a29bbbd

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/index.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ module.exports = ({ tmpdir } = {}) => {
4848
try {
4949
total = timeSpan()
5050
const compiled = await compilePromise
51-
const installAndBuildMs = total()
5251

52+
const spawnElapsed = timeSpan()
5353
const subprocess = spawn({
5454
args: JSON.stringify(args),
5555
env: {
@@ -61,28 +61,20 @@ module.exports = ({ tmpdir } = {}) => {
6161
subprocess.stdin.on('error', () => {})
6262
Readable.from(compiled.content).pipe(subprocess.stdin)
6363
const { stdout } = await subprocess
64+
const spawnMs = spawnElapsed()
6465
const { isFulfilled, value, profiling, logging } = JSON.parse(stdout)
65-
const totalMs = total()
6666
const { run, ...rest } = profiling
6767
const result = {
6868
...rest,
6969
phases: {
7070
install: compiled.install,
7171
build: compiled.build,
72-
spawn: totalMs - installAndBuildMs - run,
72+
spawn: spawnMs - run,
7373
run,
74-
total: totalMs
74+
total: total()
7575
}
7676
}
77-
debug('node', {
78-
cpu: `${Math.round(result.cpu)}ms`,
79-
memory: `${Math.round(result.memory / (1024 * 1024))}MiB`,
80-
phases: `install=${Math.round(result.phases.install)}ms build=${Math.round(
81-
result.phases.build
82-
)}ms spawn=${Math.round(result.phases.spawn)}ms run=${Math.round(
83-
result.phases.run
84-
)}ms total=${Math.round(result.phases.total)}ms`
85-
})
77+
debug('node', { cpu: result.cpu, memory: result.memory, ...result.phases })
8678

8779
return isFulfilled
8880
? { isFulfilled, value, profiling: result, logging }

test/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ test('memory profiling', async t => {
122122
t.is(value, undefined)
123123
t.is(typeof profiling.cpu, 'number')
124124
t.is(typeof profiling.memory, 'number')
125-
t.is(typeof profiling.phases.compile, 'number')
125+
t.is(typeof profiling.phases.install, 'number')
126+
t.is(typeof profiling.phases.build, 'number')
126127
t.is(typeof profiling.phases.spawn, 'number')
127128
t.is(typeof profiling.phases.run, 'number')
128129
t.is(typeof profiling.phases.total, 'number')

0 commit comments

Comments
 (0)