wukong-profiler 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/index.mjs +3 -9
- package/src/report.mjs +6 -2
- package/src/utils/diff.mjs +2 -2
- package/src/utils/profiler.mjs +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wukong-profiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "🔥 高性能 CLI/Node Profiler,支持 Flame Graph、Chrome Trace、HOT 步骤检测、性能回归分析",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"profiler",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"chalk": "^5.
|
|
77
|
-
"commander": "^
|
|
76
|
+
"chalk": "^5.6.2",
|
|
77
|
+
"commander": "^14.0.2",
|
|
78
78
|
"open": "^11.0.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@trivago/prettier-plugin-sort-imports": "
|
|
81
|
+
"@trivago/prettier-plugin-sort-imports": "6.0.0",
|
|
82
82
|
"eslint": "8.57.1",
|
|
83
83
|
"eslint-config-airbnb-base": "15.0.0",
|
|
84
84
|
"eslint-config-prettier": "10.1.8",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
89
89
|
"husky": "9.1.7",
|
|
90
90
|
"lint-staged": "16.2.7",
|
|
91
|
-
"prettier": "3.
|
|
92
|
-
"prettier-plugin-packagejson": "2.5.
|
|
93
|
-
"sort-package-json": "3.
|
|
91
|
+
"prettier": "3.7.4",
|
|
92
|
+
"prettier-plugin-packagejson": "2.5.20",
|
|
93
|
+
"sort-package-json": "3.6.0",
|
|
94
94
|
"standard-version": "9.5.0"
|
|
95
95
|
},
|
|
96
96
|
"packageManager": "yarn@1.22.22",
|
package/src/index.mjs
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { diffProfiles } from './utils/diff.mjs'
|
|
2
2
|
import { formatTime, makeBar } from './utils/format.mjs'
|
|
3
|
+
import { createProfiler } from './utils/profiler.mjs'
|
|
3
4
|
import { exportChromeTrace } from './utils/trace.mjs'
|
|
4
|
-
import { diffProfiles } from './utils/diff.mjs'
|
|
5
5
|
|
|
6
|
-
export {
|
|
7
|
-
createProfiler,
|
|
8
|
-
formatTime,
|
|
9
|
-
makeBar,
|
|
10
|
-
exportChromeTrace,
|
|
11
|
-
diffProfiles
|
|
12
|
-
}
|
|
6
|
+
export { createProfiler, formatTime, makeBar, exportChromeTrace, diffProfiles }
|
package/src/report.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// report.mjs
|
|
2
2
|
export const generateReport = (profile) => {
|
|
3
|
-
const rows = profile.events
|
|
3
|
+
const rows = profile.events
|
|
4
|
+
.map(
|
|
5
|
+
(e) => `
|
|
4
6
|
<tr class="${e.duration / profile.total > 0.8 ? 'hot' : ''}">
|
|
5
7
|
<td>${e.name}</td>
|
|
6
8
|
<td>${e.duration.toFixed(2)} ms</td>
|
|
@@ -12,7 +14,9 @@ export const generateReport = (profile) => {
|
|
|
12
14
|
: `${e.source.file}:${e.source.line}`
|
|
13
15
|
: ''
|
|
14
16
|
}</td>
|
|
15
|
-
</tr>`
|
|
17
|
+
</tr>`
|
|
18
|
+
)
|
|
19
|
+
.join('')
|
|
16
20
|
|
|
17
21
|
const html = `<!doctype html>
|
|
18
22
|
<html>
|
package/src/utils/diff.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const diffProfiles = (prev, curr, threshold = 0.2) => {
|
|
2
2
|
const map = new Map()
|
|
3
|
-
prev.events.forEach(e => map.set(e.name, e.duration))
|
|
3
|
+
prev.events.forEach((e) => map.set(e.name, e.duration))
|
|
4
4
|
const regressions = []
|
|
5
5
|
|
|
6
|
-
curr.events.forEach(e => {
|
|
6
|
+
curr.events.forEach((e) => {
|
|
7
7
|
const before = map.get(e.name)
|
|
8
8
|
if (!before) return
|
|
9
9
|
const diff = (e.duration - before) / before
|
package/src/utils/profiler.mjs
CHANGED
|
@@ -55,8 +55,7 @@ export const createProfiler = ({
|
|
|
55
55
|
const top = frames[0]
|
|
56
56
|
|
|
57
57
|
const match =
|
|
58
|
-
top.match(/\((.*):(\d+):(\d+)\)/) ||
|
|
59
|
-
top.match(/at (.*):(\d+):(\d+)/)
|
|
58
|
+
top.match(/\((.*):(\d+):(\d+)\)/) || top.match(/at (.*):(\d+):(\d+)/)
|
|
60
59
|
|
|
61
60
|
if (!match) return { raw: top }
|
|
62
61
|
|