forked from defunkt/toes
Move setPerfTiming next to perfTiming and always capture request start time
Colocate the setter with its variable for readability. Remove the conditional around performance.now() since the call is negligible and simplifies the timing logic.
This commit is contained in:
parent
c42c73fe70
commit
b9f94a6c98
|
|
@ -5,6 +5,8 @@ export type { WsData }
|
|||
|
||||
export let perfTiming = false
|
||||
|
||||
export const setPerfTiming = (on: boolean) => { perfTiming = on }
|
||||
|
||||
const pendingMessages = new Map<ServerWebSocket<WsData>, (string | ArrayBuffer | Uint8Array)[]>()
|
||||
const upstreams = new Map<ServerWebSocket<WsData>, WebSocket>()
|
||||
|
||||
|
|
@ -14,8 +16,6 @@ interface WsData {
|
|||
protocols: string[]
|
||||
}
|
||||
|
||||
export const setPerfTiming = (on: boolean) => { perfTiming = on }
|
||||
|
||||
export function extractSubdomain(host: string): string | null {
|
||||
// Strip port
|
||||
const hostname = host.replace(/:\d+$/, '')
|
||||
|
|
@ -57,7 +57,7 @@ export async function proxySubdomain(subdomain: string, req: Request): Promise<R
|
|||
headers.delete('transfer-encoding')
|
||||
|
||||
try {
|
||||
const start = perfTiming ? performance.now() : 0
|
||||
const start = performance.now()
|
||||
const res = await fetch(target, {
|
||||
method: req.method,
|
||||
headers,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user