Name application milestones with User Timing
Quick answer
Performance marks record named time points; measures record intervals between named points or supplied times. They help label phases of an application without printing arbitrary clock values.
How it works
Use performance.mark(name, options) to add a mark; optional startTime lets a fixture use an explicit nonnegative time. performance.measure(name, startMark, endMark) creates an entry with startTime and duration. Read marks and measures by name or type. Use unique names when sharing a timeline, or clear only the names owned by your feature using clearMarks and clearMeasures. Explicit fixture times illustrate semantics, not actual benchmark durations.
Local examples
Run in a fresh browser document with local synthetic data. Actual ByteMind editor support is unverified.
(async () => {const m=performance.mark("v16-start",{startTime:10}); console.log(m.entryType,m.name,m.startTime);performance.clearMarks("v16-start");})()Expected console output:
mark v16-start 10An explicitly supplied time makes the example deterministic.
Run in a fresh browser document with local synthetic data. Actual ByteMind editor support is unverified.
(async () => {performance.mark("v16-a",{startTime:10});performance.mark("v16-b",{startTime:35});const m=performance.measure("v16-span","v16-a","v16-b");console.log(m.startTime,m.duration);performance.clearMarks("v16-a");performance.clearMarks("v16-b");performance.clearMeasures("v16-span");})()Expected console output:
10 25The duration is the difference between the two explicit mark times.
Common mistakes
Do not treat measures as live timers or clear all marks belonging to other modules. A missing named mark can cause an exception.
Practice
Create named marks before and after rendering a list, read the measure and clear only your own entries.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Name application milestones with User Timing — Knowledge Check
Apply the concept and reason about local example output.
What does a PerformanceMark represent?
What does measure.duration express?
Why use feature-specific mark names?
What is the exact console output in Name application milestones with User Timing example 1?
(async () => {const m=performance.mark("v16-start",{startTime:10}); console.log(m.entryType,m.name,m.startTime);performance.clearMarks("v16-start");})()What is the exact console output in Name application milestones with User Timing example 2?
(async () => {performance.mark("v16-a",{startTime:10});performance.mark("v16-b",{startTime:35});const m=performance.measure("v16-span","v16-a","v16-b");console.log(m.startTime,m.duration);performance.clearMarks("v16-a");performance.clearMarks("v16-b");performance.clearMeasures("v16-span");})()