Nuxt/packages/cli/src/utils/memory.js

19 lines
542 B
JavaScript
Raw Normal View History

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())
}