Skip to main content

Function: formatResponseTime()

formatResponseTime(time?: number): string

Defined in: src/utils/time.ts:206

Formats response time in a human-readable format with automatic unit selection.

Parametersโ€‹

time?โ€‹

number

Response time in milliseconds (optional)

Returnsโ€‹

string

Formatted time string or fallback message

Remarksโ€‹

Automatically chooses between milliseconds and seconds based on the magnitude of the response time. Provides a fallback message for undefined or null values. Optimized for displaying network response times in monitoring interfaces.

Exampleโ€‹

formatResponseTime(234); // "234ms"
formatResponseTime(1230); // "1.23s"
formatResponseTime(0); // "0ms"
formatResponseTime(null); // "N/A" (or configured fallback)