Skip to content

Commit dfd3663

Browse files
committed
chore: add memoery usage
1 parent 69914ea commit dfd3663

File tree

8 files changed

+40
-6
lines changed

8 files changed

+40
-6
lines changed

benchmark/compile.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createCommonJS } from 'mlly'
22
import { baseCompile } from '@intlify/message-compiler'
3+
import { displayMemoryUsage } from './utils.mjs'
34

45
const { require } = createCommonJS(import.meta.url)
56
const { Suite } = require('benchmark')
@@ -23,6 +24,8 @@ async function main() {
2324
console.log(String(event.target))
2425
})
2526
.run()
27+
28+
displayMemoryUsage()
2629
}
2730

2831
main().catch(err => {

benchmark/complex-jit-aot.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@intlify/core-base'
1212
import { createI18n } from 'vue-i18n'
1313
import { resolve, dirname } from 'pathe'
14-
import { readJson } from './utils.mjs'
14+
import { readJson, displayMemoryUsage } from './utils.mjs'
1515

1616
const { require } = createCommonJS(import.meta.url)
1717
const { Suite } = require('benchmark')
@@ -76,6 +76,8 @@ async function main() {
7676
console.log(String(event.target))
7777
})
7878
.run()
79+
80+
displayMemoryUsage()
7981
}
8082

8183
main().catch(err => {

benchmark/complex-jit.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from '@intlify/core-base'
1111
import { createI18n } from 'vue-i18n'
1212
import { resolve, dirname } from 'pathe'
13-
import { readJson } from './utils.mjs'
13+
import { readJson, displayMemoryUsage } from './utils.mjs'
1414

1515
const { require } = createCommonJS(import.meta.url)
1616
const { Suite } = require('benchmark')
@@ -65,6 +65,8 @@ async function main() {
6565
console.log(String(event.target))
6666
})
6767
.run()
68+
69+
displayMemoryUsage()
6870
}
6971

7072
main().catch(err => {

benchmark/complex.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@intlify/core-base'
77
import { createI18n } from 'vue-i18n'
88
import { resolve, dirname } from 'pathe'
9-
import { readJson } from './utils.mjs'
9+
import { readJson, displayMemoryUsage } from './utils.mjs'
1010

1111
const { require } = createCommonJS(import.meta.url)
1212
const { Suite } = require('benchmark')
@@ -59,6 +59,8 @@ async function main() {
5959
console.log(String(event.target))
6060
})
6161
.run()
62+
63+
displayMemoryUsage()
6264
}
6365

6466
main().catch(err => {

benchmark/simple-jit-aot.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@intlify/core-base'
1212
import { createI18n } from 'vue-i18n'
1313
import { resolve, dirname } from 'pathe'
14-
import { readJson } from './utils.mjs'
14+
import { readJson, displayMemoryUsage } from './utils.mjs'
1515

1616
const { require } = createCommonJS(import.meta.url)
1717
const { Suite } = require('benchmark')
@@ -69,6 +69,8 @@ async function main() {
6969
console.log(String(event.target))
7070
})
7171
.run()
72+
73+
displayMemoryUsage()
7274
}
7375

7476
main().catch(err => {

benchmark/simple-jit.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from '@intlify/core-base'
1111
import { createI18n } from 'vue-i18n'
1212
import { resolve, dirname } from 'pathe'
13-
import { readJson } from './utils.mjs'
13+
import { readJson, displayMemoryUsage } from './utils.mjs'
1414

1515
const { require } = createCommonJS(import.meta.url)
1616
const { Suite } = require('benchmark')
@@ -58,6 +58,8 @@ async function main() {
5858
console.log(String(event.target))
5959
})
6060
.run()
61+
62+
displayMemoryUsage()
6163
}
6264

6365
main().catch(err => {

benchmark/simple.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@intlify/core-base'
77
import { createI18n } from 'vue-i18n'
88
import { resolve, dirname } from 'pathe'
9-
import { readJson } from './utils.mjs'
9+
import { readJson, displayMemoryUsage } from './utils.mjs'
1010

1111
const { require } = createCommonJS(import.meta.url)
1212
const { Suite } = require('benchmark')
@@ -52,6 +52,8 @@ async function main() {
5252
console.log(String(event.target))
5353
})
5454
.run()
55+
56+
displayMemoryUsage()
5557
}
5658

5759
main().catch(err => {

benchmark/utils.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)