forked from dev-five-git/devup-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.js
More file actions
110 lines (100 loc) · 3.18 KB
/
benchmark.js
File metadata and controls
110 lines (100 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { existsSync, readdirSync, rmSync, statSync } from 'node:fs'
import { join } from 'node:path'
import { execSync } from 'child_process'
function clearBuildFile() {
if (existsSync('./benchmark/next-stylex/.next'))
rmSync('./benchmark/next-stylex/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-vanilla-extract/.next'))
rmSync('./benchmark/next-vanilla-extract/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-tailwind/.next'))
rmSync('./benchmark/next-tailwind/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-kuma-ui/.next'))
rmSync('./benchmark/next-kuma-ui/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-chakra-ui/.next'))
rmSync('./benchmark/next-chakra-ui/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-devup-ui/.next'))
rmSync('./benchmark/next-devup-ui/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-devup-ui-single/.next'))
rmSync('./benchmark/next-devup-ui-single/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-mui/.next'))
rmSync('./benchmark/next-mui/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-panda-css/.next'))
rmSync('./benchmark/next-panda-css/.next', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-devup-ui/df'))
rmSync('./benchmark/next-devup-ui/df', {
recursive: true,
force: true,
})
if (existsSync('./benchmark/next-devup-ui-single/df'))
rmSync('./benchmark/next-devup-ui-single/df', {
recursive: true,
force: true,
})
}
function checkDirSize(path) {
let totalSize = 0
function calculateSize(directory) {
const entries = readdirSync(directory)
for (const entry of entries) {
const entryPath = join(directory, entry)
if (statSync(entryPath).isDirectory()) {
calculateSize(entryPath) // 재귀적으로 하위 폴더 크기 계산
} else {
const stats = statSync(entryPath)
totalSize += stats.size // 파일 크기 합산
}
}
}
calculateSize(path)
return totalSize
}
clearBuildFile()
function benchmark(target) {
performance.mark(target + '-start')
console.profile(target)
execSync('pnpm -F next-' + target + '-benchmark build', {
stdio: 'inherit',
})
console.profileEnd(target)
performance.mark(target + '-end')
performance.measure(target, target + '-start', target + '-end')
return `${target} ${(performance.getEntriesByName(target)[0].duration / 1000).toFixed(2).toLocaleString()}s ${checkDirSize('./benchmark/next-' + target + '/.next').toLocaleString()} bytes`
}
let result = []
result.push(benchmark('tailwind'))
result.push(benchmark('stylex'))
result.push(benchmark('vanilla-extract'))
result.push(benchmark('kuma-ui'))
result.push(benchmark('panda-css'))
result.push(benchmark('chakra-ui'))
result.push(benchmark('mui'))
result.push(benchmark('devup-ui'))
result.push(benchmark('devup-ui-single'))
console.info(result.join('\n'))