mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 00:52:01 +00:00
e7cc2757c3
Co-authored-by: Alexander Lichter <manniL@gmx.net>
19 lines
542 B
JavaScript
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())
|
|
}
|