Nuxt/packages/cli/src/utils/memory.js
pooya parsa e7cc2757c3 refactor: update eslint-config to 1.x
Co-authored-by: Alexander Lichter <manniL@gmx.net>
2019-07-10 15:15:49 +04:30

19 lines
542 B
JavaScript

import chalk from 'chalk'
import consola from 'consola'
import prettyBytes from 'pretty-bytes'
export function getMemoryUsage () {
// https://nodejs.org/api/process.html#process_process_memoryusage
const { heapUsed, rss } = process.memoryUsage()
return { heap: heapUsed, rss }
}
export function getFormattedMemoryUsage () {
const { heap, rss } = getMemoryUsage()
return `Memory usage: ${chalk.bold(prettyBytes(heap))} (RSS: ${prettyBytes(rss)})`
}
export function showMemoryUsage () {
consola.info(getFormattedMemoryUsage())
}