gossamer/performance/measure
Records a span between two timestamps on the performance
timeline. Anchor the span on raw Duration values from
performance.now or from a previously
recorded entry’s start_time.
See Performance.measure on MDN.
Types
A measure on the performance timeline.
pub type Measure {
Measure(
name: String,
start_time: duration.Duration,
duration: duration.Duration,
detail: option.Option(dynamic.Dynamic),
)
}
Constructors
-
Measure( name: String, start_time: duration.Duration, duration: duration.Duration, detail: option.Option(dynamic.Dynamic), )Arguments
- name
-
The measure’s name.
- start_time
-
When the span begins, relative to
performance.time_origin. - duration
-
The span’s length.
- detail
-
Arbitrary metadata attached at construction via
set_detail.Nonewhen nothing is attached.
Values
pub fn between(
name: String,
from from: duration.Duration,
to to: duration.Duration,
) -> Measure
Creates a Measure named name spanning from from to to (both
relative to
performance.time_origin). The
duration field is computed as to - from. Negative endpoints
and a negative computed duration (i.e. to < from) are clamped
to zero. Pass to record to write to the timeline.
pub fn between_marks(
name: String,
from from_mark: String,
to to_mark: String,
) -> Result(Measure, Nil)
Creates a Measure named name spanning from the most recent
mark named from to the most recent mark named to. Returns
Error(Nil) when either mark name has no recorded marks on the
performance timeline. Pass to record to write the
measure.
pub fn entries() -> List(Measure)
Returns every measure currently on the performance timeline.
pub fn entries_by_name(name: String) -> List(Measure)
Returns the measures on the performance timeline whose name
matches name.
pub fn from_entry(
entry: performance_entry.PerformanceEntry,
) -> Result(Measure, Nil)
Projects a
PerformanceEntry
to a Measure. Returns Error(Nil) if the entry
isn’t a measure.
pub fn record(measure: Measure) -> Measure
Records the measure on the performance timeline. Returns the
Measure unchanged.
pub fn set_detail(
measure: Measure,
detail: dynamic.Dynamic,
) -> Measure
Sets arbitrary metadata attached to the measure, exposed on the
recorded Measure’s detail field.
pub fn set_duration(
measure: Measure,
duration: duration.Duration,
) -> Measure
Sets the duration of the measure. Negative inputs are clamped to zero.
pub fn set_start_time(
measure: Measure,
start_time: duration.Duration,
) -> Measure
Sets the start time of the measure relative to
performance.time_origin.
Negative inputs are clamped to zero.