@rtorcato/browser-common / performance
performance
Functions
isPerformanceApiAvailable()
isPerformanceApiAvailable():
boolean
Defined in: performance/index.ts:9
Checks if the Performance API is available in the current environment.
Returns
boolean
Example
import { isPerformanceApiAvailable } from '@rtorcato/browser-common/performance'
if (isPerformanceApiAvailable()) trace()
now()
now():
number
Defined in: performance/index.ts:23
Returns the current high-resolution timestamp (in milliseconds). Falls back to Date.now() if not available.
Returns
number
Example
import { now } from '@rtorcato/browser-common/performance'
const start = now()
const elapsed = now() - start
getPerformanceEntriesByType()
getPerformanceEntriesByType(
type):PerformanceEntry[]
Defined in: performance/index.ts:40
Gets all performance entries of a given type (e.g., 'resource', 'mark', 'measure').
Parameters
type
string
The entry type.
Returns
PerformanceEntry[]
An array of PerformanceEntry objects, or an empty array if not supported.
Example
import { getPerformanceEntriesByType } from '@rtorcato/browser-common/performance'
const resources = getPerformanceEntriesByType('resource')
mark()
mark(
name):void
Defined in: performance/index.ts:56
Marks a named timestamp in the performance timeline.
Parameters
name
string
The mark name.
Returns
void
Example
import { mark } from '@rtorcato/browser-common/performance'
mark('boot-start')
measure()
measure(
name,startMark,endMark):void
Defined in: performance/index.ts:74
Measures the time between two marks.
Parameters
name
string
The measure name.
startMark
string
The starting mark name.
endMark
string
The ending mark name.
Returns
void
Example
import { mark, measure } from '@rtorcato/browser-common/performance'
mark('start'); doWork(); mark('end')
measure('work', 'start', 'end')