feat: export discord/AppStartPerformance, add Startup Timing logging
This commit is contained in:
parent
b785bc574a
commit
2de47ff046
7 changed files with 62 additions and 0 deletions
|
|
@ -12,6 +12,9 @@
|
|||
"./native": {
|
||||
"default": "./src/native.ts"
|
||||
},
|
||||
"./preinit": {
|
||||
"default": "./src/preinit.ts"
|
||||
},
|
||||
"./types": {
|
||||
"types": "./types/index.ts"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import { byName, byProps } from '@revenge-mod/modules/finders/filters'
|
|||
|
||||
import type { DiscordModules } from '../types'
|
||||
|
||||
export * from './preinit'
|
||||
|
||||
export * as flux from './flux'
|
||||
export * as native from './native'
|
||||
|
||||
|
|
|
|||
18
lib/discord/src/preinit.ts
Normal file
18
lib/discord/src/preinit.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { byDependencies, byProps, moduleStateAware } from '@revenge-mod/modules/finders/filters'
|
||||
import { lookupModule } from '@revenge-mod/modules/finders'
|
||||
|
||||
import type { DiscordModules } from '../types'
|
||||
|
||||
// ../discord_common/js/shared/AppStartPerformance.tsx
|
||||
export const AppStartPerformance = lookupModule(
|
||||
moduleStateAware(
|
||||
byProps<DiscordModules.AppStartPerformance>('markAndLog'),
|
||||
// biome-ignore lint/suspicious/noSparseArray: Nah
|
||||
byDependencies([-1, , , 2]),
|
||||
),
|
||||
{
|
||||
includeUninitialized: true,
|
||||
},
|
||||
)!
|
||||
|
||||
AppStartPerformance.mark('👊', 'Preinit')
|
||||
|
|
@ -69,6 +69,16 @@ export namespace DiscordModules {
|
|||
}
|
||||
}
|
||||
|
||||
export namespace AppStartPerformance {
|
||||
export type MarkArgs = [emoji: string, log: string, delta?: number]
|
||||
}
|
||||
|
||||
export interface AppStartPerformance {
|
||||
mark(...args: AppStartPerformance.MarkArgs): void
|
||||
markAndLog(logger: InstanceType<DiscordModules.Logger>, ...args: AppStartPerformance.MarkArgs): void
|
||||
[index: string]: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* Discord's `Logger` class.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ onModuleFirstRequired(0, function onceIndexRequired() {
|
|||
// Initialize preinit libraries
|
||||
require('@revenge-mod/modules/preinit')
|
||||
require('@revenge-mod/react/preinit')
|
||||
require('@revenge-mod/discord/preinit')
|
||||
|
||||
onModuleInitialized(0, function onceIndexInitialized() {
|
||||
runCatching(() => {
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
import './timing-log'
|
||||
import './staff-settings'
|
||||
|
|
|
|||
27
plugins/timing-log/index.ts
Normal file
27
plugins/timing-log/index.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { AppStartPerformance } from '@revenge-mod/discord'
|
||||
|
||||
import { PluginFlags } from '@revenge-mod/plugins'
|
||||
import { registerPlugin } from '@revenge-mod/plugins/_'
|
||||
|
||||
AppStartPerformance.mark('👊', 'Plugins register')
|
||||
|
||||
const tsReg = performance.now()
|
||||
let tsInit: number
|
||||
|
||||
registerPlugin(
|
||||
{
|
||||
id: 'revenge.timing-log',
|
||||
name: 'Startup Timing Log',
|
||||
description: "Log Revenge's startup timing into Discord's Startup Timing",
|
||||
},
|
||||
{
|
||||
init() {
|
||||
tsInit = performance.now()
|
||||
AppStartPerformance.mark('👊', 'Plugins init', tsInit - tsReg)
|
||||
},
|
||||
start() {
|
||||
AppStartPerformance.mark('👊', 'Plugins start', performance.now() - tsInit)
|
||||
},
|
||||
},
|
||||
PluginFlags.Internal | PluginFlags.Enabled,
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue