mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-18 18:02:08 +08:00
chore(dev): add React profiling and focused A/B workflows
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import type { ProfilerOnRenderCallback } from 'react'
|
||||
|
||||
export type ProfileRecord = Parameters<ProfilerOnRenderCallback>
|
||||
|
||||
const records: ProfileRecord[] = []
|
||||
|
||||
export const recordRender: ProfilerOnRenderCallback = (...record) => {
|
||||
if (records.length === 1000) records.shift()
|
||||
records.push(record)
|
||||
}
|
||||
|
||||
export const profiler = {
|
||||
read: () => records.map((record) => [...record]),
|
||||
clear: () => {
|
||||
records.length = 0
|
||||
},
|
||||
}
|
||||
|
||||
Object.assign(window, { __CVR_REACT_PROFILER__: profiler })
|
||||
Reference in New Issue
Block a user