File tree Expand file tree Collapse file tree 8 files changed +40
-6
lines changed Expand file tree Collapse file tree 8 files changed +40
-6
lines changed Original file line number Diff line number Diff line change 11import { createCommonJS } from 'mlly'
22import { baseCompile } from '@intlify/message-compiler'
3+ import { displayMemoryUsage } from './utils.mjs'
34
45const { require } = createCommonJS ( import . meta. url )
56const { Suite } = require ( 'benchmark' )
@@ -23,6 +24,8 @@ async function main() {
2324 console . log ( String ( event . target ) )
2425 } )
2526 . run ( )
27+
28+ displayMemoryUsage ( )
2629}
2730
2831main ( ) . catch ( err => {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
1111} from '@intlify/core-base'
1212import { createI18n } from 'vue-i18n'
1313import { resolve , dirname } from 'pathe'
14- import { readJson } from './utils.mjs'
14+ import { readJson , displayMemoryUsage } from './utils.mjs'
1515
1616const { require } = createCommonJS ( import . meta. url )
1717const { Suite } = require ( 'benchmark' )
@@ -76,6 +76,8 @@ async function main() {
7676 console . log ( String ( event . target ) )
7777 } )
7878 . run ( )
79+
80+ displayMemoryUsage ( )
7981}
8082
8183main ( ) . catch ( err => {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010} from '@intlify/core-base'
1111import { createI18n } from 'vue-i18n'
1212import { resolve , dirname } from 'pathe'
13- import { readJson } from './utils.mjs'
13+ import { readJson , displayMemoryUsage } from './utils.mjs'
1414
1515const { require } = createCommonJS ( import . meta. url )
1616const { Suite } = require ( 'benchmark' )
@@ -65,6 +65,8 @@ async function main() {
6565 console . log ( String ( event . target ) )
6666 } )
6767 . run ( )
68+
69+ displayMemoryUsage ( )
6870}
6971
7072main ( ) . catch ( err => {
Original file line number Diff line number Diff line change 66} from '@intlify/core-base'
77import { createI18n } from 'vue-i18n'
88import { resolve , dirname } from 'pathe'
9- import { readJson } from './utils.mjs'
9+ import { readJson , displayMemoryUsage } from './utils.mjs'
1010
1111const { require } = createCommonJS ( import . meta. url )
1212const { Suite } = require ( 'benchmark' )
@@ -59,6 +59,8 @@ async function main() {
5959 console . log ( String ( event . target ) )
6060 } )
6161 . run ( )
62+
63+ displayMemoryUsage ( )
6264}
6365
6466main ( ) . catch ( err => {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
1111} from '@intlify/core-base'
1212import { createI18n } from 'vue-i18n'
1313import { resolve , dirname } from 'pathe'
14- import { readJson } from './utils.mjs'
14+ import { readJson , displayMemoryUsage } from './utils.mjs'
1515
1616const { require } = createCommonJS ( import . meta. url )
1717const { Suite } = require ( 'benchmark' )
@@ -69,6 +69,8 @@ async function main() {
6969 console . log ( String ( event . target ) )
7070 } )
7171 . run ( )
72+
73+ displayMemoryUsage ( )
7274}
7375
7476main ( ) . catch ( err => {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010} from '@intlify/core-base'
1111import { createI18n } from 'vue-i18n'
1212import { resolve , dirname } from 'pathe'
13- import { readJson } from './utils.mjs'
13+ import { readJson , displayMemoryUsage } from './utils.mjs'
1414
1515const { require } = createCommonJS ( import . meta. url )
1616const { Suite } = require ( 'benchmark' )
@@ -58,6 +58,8 @@ async function main() {
5858 console . log ( String ( event . target ) )
5959 } )
6060 . run ( )
61+
62+ displayMemoryUsage ( )
6163}
6264
6365main ( ) . catch ( err => {
Original file line number Diff line number Diff line change 66} from '@intlify/core-base'
77import { createI18n } from 'vue-i18n'
88import { resolve , dirname } from 'pathe'
9- import { readJson } from './utils.mjs'
9+ import { readJson , displayMemoryUsage } from './utils.mjs'
1010
1111const { require } = createCommonJS ( import . meta. url )
1212const { Suite } = require ( 'benchmark' )
@@ -52,6 +52,8 @@ async function main() {
5252 console . log ( String ( event . target ) )
5353 } )
5454 . run ( )
55+
56+ displayMemoryUsage ( )
5557}
5658
5759main ( ) . catch ( err => {
Original file line number Diff line number Diff line change @@ -5,3 +5,22 @@ export async function readJson(path) {
55 const data = await fs . readFile ( path , 'utf8' )
66 return JSON . parse ( data )
77}
8+
9+ const numberFormatter = new Intl . NumberFormat ( 'en' , {
10+ maximumFractionDigits : 2 ,
11+ minimumFractionDigits : 2
12+ } )
13+
14+ function displaySize ( bytes ) {
15+ return `${ numberFormatter . format ( bytes / 1000 ) } kB`
16+ }
17+
18+ export function displayMemoryUsage ( ) {
19+ const heap = process . memoryUsage ( )
20+ const msg = [ ]
21+ for ( const key in heap ) {
22+ msg . push ( `${ key } : ${ displaySize ( heap [ key ] ) } ` )
23+ }
24+ console . log ( )
25+ console . log ( 'memory usage:' , msg . join ( ', ' ) )
26+ }
You can’t perform that action at this time.
0 commit comments