Wren

Module performance

High Resolution Time and User Timing: performance.now() and timeOrigin on the page's own timeline, mark / measure, getEntriesByName / getEntriesByType (one entry at a time), clearMarks / clearMeasures. Entries are kept in startTime order, at most performance.max_user_timing_entries (the oldest go first).

Exposed to: Window, Worker. Source: api/performance.widl.

Odin: import "wren:performance".

Types

enum PerformanceEntryType : i32

The entries a query matches (Any: every user timing entry). The values from Navigation on are the browser's timeline entries (Performance_timeline): the document's navigation, its resources, paints, slow inputs and long tasks (Long_Task: a task of the window's realm that took 50 ms or more), the largest contentful paint, the layout shifts, the element timing entries and the visibility-state changes.

membervalue
Any0
Mark1
Measure2
Navigation3
Resource4
Paint5
Event6
First_Input7
Long_Task8
Largest_Contentful_Paint9
Layout_Shift10
Element11
Visibility_State12
Long_Animation_Frame13
Script14

callback TimelineCallback

void TimelineCallback(i32 user, i32 kinds)

A function of the realm the browser calls when a kind of timeline entry it was asked for (Performance_timelineInterest) has new entries: kinds has one bit for each (1 << PerformanceEntryType).

Functions

Performance_now

f64 Performance_now()

performance.now()

Odin: performance.now.

Host: Performance_now :: proc(c: ^Call) -> f64

Performance_timeOrigin

f64 Performance_timeOrigin()

performance.timeOrigin (ms since the Unix epoch).

Odin: performance.timeOrigin.

Host: Performance_timeOrigin :: proc(c: ^Call) -> f64

Performance_mark

void Performance_mark(string name, f64 start_time = -1) raises

performance.mark(name, {startTime}): a negative or NaN start_time means now. Syntax for an empty name.

Odin: performance.mark.

Raises: returns an Error (see web).

Host: Performance_mark :: proc(c: ^Call, name: string, start_time: f64) -> Api_Error

Performance_measure

void Performance_measure(string name, string start_mark = "", string end_mark = "") raises

performance.measure(name, startMark, endMark): an empty start is the time origin, an empty end is now. Syntax for a mark that does not exist.

Odin: performance.measure.

Raises: returns an Error (see web).

Host: Performance_measure :: proc(c: ^Call, name: string, start_mark: string, end_mark: string) -> Api_Error

Performance_measureTimes

void Performance_measureTimes(string name, f64 start, f64 end) raises

performance.measure(name, {start, end})

Odin: performance.measureTimes.

Raises: returns an Error (see web).

Host: Performance_measureTimes :: proc(c: ^Call, name: string, start: f64, end: f64) -> Api_Error

Performance_entryCount

i32 Performance_entryCount(string name, PerformanceEntryType entry_type)

How many entries match name ("" = any) and entry_type.

Odin: performance.entryCount.

Host: Performance_entryCount :: proc(c: ^Call, name: string, entry_type: Api_PerformanceEntryType) -> i32

Performance_entryStartTime

f64 Performance_entryStartTime(string name, PerformanceEntryType entry_type, i32 index)

startTime of the index-th matching entry (NaN when none).

Odin: performance.entryStartTime.

Host: Performance_entryStartTime :: proc(c: ^Call, name: string, entry_type: Api_PerformanceEntryType, index: i32) -> f64

Performance_entryDuration

f64 Performance_entryDuration(string name, PerformanceEntryType entry_type, i32 index)

duration of the index-th matching entry (NaN when none).

Odin: performance.entryDuration.

Host: Performance_entryDuration :: proc(c: ^Call, name: string, entry_type: Api_PerformanceEntryType, index: i32) -> f64

Performance_entryName

string Performance_entryName(string name, PerformanceEntryType entry_type, i32 index) raises

name of the index-th matching entry: Not_Found when none.

Odin: performance.entryName.

Raises: returns an Error (see web).

Host: Performance_entryName :: proc(c: ^Call, name: string, entry_type: Api_PerformanceEntryType, index: i32) -> (string, Api_Error)

Performance_entryType

PerformanceEntryType Performance_entryType(string name, PerformanceEntryType entry_type, i32 index) raises

entryType of the index-th matching entry (Mark or Measure): Not_Found when none.

Odin: performance.entryType.

Raises: returns an Error (see web).

Host: Performance_entryType :: proc(c: ^Call, name: string, entry_type: Api_PerformanceEntryType, index: i32) -> (Api_PerformanceEntryType, Api_Error)

Performance_clearMarks

void Performance_clearMarks(string name = "")

performance.clearMarks(name): "" clears all.

Odin: performance.clearMarks.

Host: Performance_clearMarks :: proc(c: ^Call, name: string)

Performance_clearMeasures

void Performance_clearMeasures(string name = "")

performance.clearMeasures(name): "" clears all.

Odin: performance.clearMeasures.

Host: Performance_clearMeasures :: proc(c: ^Call, name: string)

Performance_timeline

string Performance_timeline(PerformanceEntryType entry_type, u64 from_seq = 0)

The timeline entries of entry_type (Navigation, Resource, Paint, Event or First_Input) whose sequence number is at least from_seq, in order, as a JSON array of objects with the members of the entry's interface (name, startTime, duration, initiatorType, responseStart...) and seq. A kept entry never changes; the buffers drop their oldest entries (performance.resource_timing_entries...).

Odin: performance.timeline.

Host: Performance_timeline :: proc(c: ^Call, entry_type: Api_PerformanceEntryType, from_seq: u64) -> string

Performance_timelineNextSeq

u64 Performance_timelineNextSeq(PerformanceEntryType entry_type)

The sequence number the next entry of this kind will have.

Odin: performance.timelineNextSeq.

Host: Performance_timelineNextSeq :: proc(c: ^Call, entry_type: Api_PerformanceEntryType) -> u64

Performance_timelineNode

u64 Performance_timelineNode(PerformanceEntryType entry_type, u64 seq, u32 index)

Wraps the DOM node a timeline entry refers to and returns its handle, or 0 when there is none or it is no longer in the document: the element of the index-th member of entry seq of entry_type — for Largest_Contentful_Paint and Element, index 0 is the entry's own element (its element attribute); for Layout_Shift, index i is the node of its i-th source (LayoutShiftAttribution.node). The engine carries the other members of each entry in the JSON of Performance_timeline; only live node handles come from here (a handle cannot be put in JSON and stay valid).

Odin: performance.timelineNode.

Host: Performance_timelineNode :: proc(c: ^Call, entry_type: Api_PerformanceEntryType, seq: u64, index: u32) -> u64

Performance_timelineInterest

void Performance_timelineInterest(u32 kinds)

The kinds (bits 1 << PerformanceEntryType) a PerformanceObserver wants to hear of: only those wake the realm.

Odin: performance.timelineInterest.

Host: Performance_timelineInterest :: proc(c: ^Call, kinds: u32)

Performance_onTimeline

void Performance_onTimeline(TimelineCallback callback, i32 user = 0)

Where the browser announces new entries of the kinds of Performance_timelineInterest (a task of the page).

Odin: performance.onTimeline.

Host: Performance_onTimeline :: proc(c: ^Call, callback: u32, user: i32)

Performance_setResourceTimingBufferSize

void Performance_setResourceTimingBufferSize(u32 entries)

performance.setResourceTimingBufferSize(n) / performance.clearResourceTimings().

Odin: performance.setResourceTimingBufferSize.

Host: Performance_setResourceTimingBufferSize :: proc(c: ^Call, entries: u32)

Performance_clearResourceTimings

void Performance_clearResourceTimings()

Odin: performance.clearResourceTimings.

Host: Performance_clearResourceTimings :: proc(c: ^Call)

Performance_timingOf

f64 Performance_timingOf(i32 which)

performance.timing (Navigation Timing 1): the moment of attribute which of PerformanceTiming (0 navigationStart, 1 unloadEventStart ... 20 loadEventEnd, in the interface's order) on the page's timeline (ms since the time origin), or NaN when it has not happened or does not apply (the attribute is then 0). The network phases of the document's own fetch are not measured: they are all the time origin.

Odin: performance.timingOf.

Host: Performance_timingOf :: proc(c: ^Call, which: i32) -> f64

Edit this page on GitHub