Skip to content

Commit 12aa95e

Browse files
committed
chore: fix benchmark
1 parent 959f271 commit 12aa95e

File tree

10 files changed

+53
-40
lines changed

10 files changed

+53
-40
lines changed

benchmark/compile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createCommonJS } from 'mlly'
21
import { baseCompile } from '@intlify/message-compiler'
2+
import { createCommonJS } from 'mlly'
33
import { displayMemoryUsage } from './utils.mjs'
44

55
const { require } = createCommonJS(import.meta.url)

benchmark/complex-jit-aot.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
global.__INTLIFY_JIT_COMPILATION__ = true // set JIT mode for Node.js
22

3-
import { createCommonJS } from 'mlly'
4-
import { baseCompile } from '@intlify/message-compiler'
53
import {
6-
translate,
7-
createCoreContext,
4+
clearCompileCache,
85
compile,
6+
createCoreContext,
97
registerMessageCompiler,
10-
clearCompileCache
8+
translate
119
} from '@intlify/core-base'
10+
import { baseCompile } from '@intlify/message-compiler'
11+
import { createCommonJS } from 'mlly'
12+
import { dirname, resolve } from 'node:path'
1213
import { createI18n } from 'vue-i18n'
13-
import { resolve, dirname } from 'path'
14-
import { readJson, displayMemoryUsage } from './utils.mjs'
14+
import { displayMemoryUsage, readJson } from './utils.mjs'
1515

1616
const { require } = createCommonJS(import.meta.url)
1717
const { Suite } = require('benchmark')
@@ -34,6 +34,8 @@ async function main() {
3434
console.log(`complex pattern on ${len} resources (JIT + AOT):`)
3535
console.log()
3636

37+
resources['no apples'] = 'no apples'
38+
3739
registerMessageCompiler(compile)
3840
const precompiledResources = precompile(resources)
3941

benchmark/complex-jit.mjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
global.__INTLIFY_JIT_COMPILATION__ = true // set JIT mode for Node.js
22

3-
import { createCommonJS } from 'mlly'
43
import {
5-
translate,
6-
createCoreContext,
4+
clearCompileCache,
75
compile,
6+
createCoreContext,
87
registerMessageCompiler,
9-
clearCompileCache
8+
translate
109
} from '@intlify/core-base'
10+
import { createCommonJS } from 'mlly'
11+
import { dirname, resolve } from 'node:path'
1112
import { createI18n } from 'vue-i18n'
12-
import { resolve, dirname } from 'path'
13-
import { readJson, displayMemoryUsage } from './utils.mjs'
13+
import { displayMemoryUsage, readJson } from './utils.mjs'
1414

1515
const { require } = createCommonJS(import.meta.url)
1616
const { Suite } = require('benchmark')
@@ -24,6 +24,8 @@ async function main() {
2424
console.log(`complex pattern on ${len} resources (JIT):`)
2525
console.log()
2626

27+
resources['no apples'] = 'no apples'
28+
2729
registerMessageCompiler(compile)
2830

2931
const ctx = createCoreContext({

benchmark/complex.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { createCommonJS } from 'mlly'
21
import {
3-
translate,
2+
clearCompileCache,
43
createCoreContext,
5-
clearCompileCache
4+
translate
65
} from '@intlify/core-base'
6+
import { createCommonJS } from 'mlly'
7+
import { dirname, resolve } from 'node:path'
78
import { createI18n } from 'vue-i18n'
8-
import { resolve, dirname } from 'path'
9-
import { readJson, displayMemoryUsage } from './utils.mjs'
9+
import { displayMemoryUsage, readJson } from './utils.mjs'
1010

1111
const { require } = createCommonJS(import.meta.url)
1212
const { Suite } = require('benchmark')
@@ -20,6 +20,8 @@ async function main() {
2020
console.log(`complex pattern on ${len} resources (AOT):`)
2121
console.log()
2222

23+
resources['no apples'] = 'no apples'
24+
2325
const ctx = createCoreContext({
2426
locale: 'en',
2527
modifiers: {

benchmark/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from 'child_process'
1+
import { spawn } from 'node:child_process'
22

33
function run(pattner) {
44
return new Promise((resolve, reject) => {

benchmark/simple-jit-aot.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
global.__INTLIFY_JIT_COMPILATION__ = true // set JIT mode for Node.js
22

3-
import { createCommonJS } from 'mlly'
4-
import { baseCompile } from '@intlify/message-compiler'
53
import {
6-
translate,
7-
createCoreContext,
4+
clearCompileCache,
85
compile,
6+
createCoreContext,
97
registerMessageCompiler,
10-
clearCompileCache
8+
translate
119
} from '@intlify/core-base'
10+
import { baseCompile } from '@intlify/message-compiler'
11+
import { createCommonJS } from 'mlly'
12+
import { dirname, resolve } from 'node:path'
1213
import { createI18n } from 'vue-i18n'
13-
import { resolve, dirname } from 'path'
14-
import { readJson, displayMemoryUsage } from './utils.mjs'
14+
import { displayMemoryUsage, readJson } from './utils.mjs'
1515

1616
const { require } = createCommonJS(import.meta.url)
1717
const { Suite } = require('benchmark')

benchmark/simple-jit.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
global.__INTLIFY_JIT_COMPILATION__ = true // set JIT mode for Node.js
22

3-
import { createCommonJS } from 'mlly'
43
import {
5-
translate,
6-
createCoreContext,
4+
clearCompileCache,
75
compile,
6+
createCoreContext,
87
registerMessageCompiler,
9-
clearCompileCache
8+
translate
109
} from '@intlify/core-base'
10+
import { createCommonJS } from 'mlly'
11+
import { dirname, resolve } from 'node:path'
1112
import { createI18n } from 'vue-i18n'
12-
import { resolve, dirname } from 'path'
13-
import { readJson, displayMemoryUsage } from './utils.mjs'
13+
import { displayMemoryUsage, readJson } from './utils.mjs'
1414

1515
const { require } = createCommonJS(import.meta.url)
1616
const { Suite } = require('benchmark')

benchmark/simple.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { createCommonJS } from 'mlly'
21
import {
3-
translate,
2+
clearCompileCache,
43
createCoreContext,
5-
clearCompileCache
4+
translate
65
} from '@intlify/core-base'
6+
import { createCommonJS } from 'mlly'
7+
import { dirname, resolve } from 'node:path'
78
import { createI18n } from 'vue-i18n'
8-
import { resolve, dirname } from 'path'
9-
import { readJson, displayMemoryUsage } from './utils.mjs'
9+
import { displayMemoryUsage, readJson } from './utils.mjs'
1010

1111
const { require } = createCommonJS(import.meta.url)
1212
const { Suite } = require('benchmark')

benchmark/utils.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs/promises'
1+
import fs from 'node:fs/promises'
22

33
export async function readJson(path) {
44
const data = await fs.readFile(path, 'utf8')

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
"url": "https://github.com/inlitify/vue-i18n/issues"
1515
},
1616
"scripts": {
17-
"benchmark": "node ./benchmark/index.mjs",
17+
"bench": "node ./benchmark/index.mjs",
18+
"bench:compile": "node ./benchmark/compile.mjs",
19+
"bench:simple": "node ./benchmark/simple.mjs",
20+
"bench:simple-jit": "node ./benchmark/simple-jit.mjs",
21+
"bench:simple-jit-aot": "node ./benchmark/simple-jit-aot.mjs",
22+
"bench:complex": "node ./benchmark/complex.mjs",
23+
"bench:complex-jit": "node ./benchmark/complex-jit.mjs",
24+
"bench:complex-jit-aot": "node ./benchmark/complex-jit-aot.mjs",
1825
"build": "tsx ./scripts/build.ts",
1926
"build:explorer": "pnpm --filter @intlify/message-format-explorer build",
2027
"build:size": "pnpm build && run-p build:size-*",

0 commit comments

Comments
 (0)