Profile

View source

Represents the timing value for one labeled measurement.

Profiler#start records when the measurement starts, and Profiler#end records the duration when it ends. Use Profiler to create and access profiles, and use the static serialization methods to preserve their values.

Constructor


constructor()

Properties


delta: number

View source

Duration measured by the most recent Profiler#end, in milliseconds. It remains unchanged until a matching label is ended.

Default: 0

Methods


staticserialize(value: Profile): ProfileSerial

View source

Converts a profile to its serializable plain-object representation.

The returned object contains only the current lastTick and delta numbers. It is a new object, so changing it does not mutate value.

Parameters

NameDescriptionDefault
value

Profile to serialize.

—

Returns

Serialized timestamp and duration.

staticdeserialize(value: ProfileSerial, out?: Profile): Profile

View source

Loads serialized values into a profile.

The supplied out instance is reused when provided; otherwise a new Profile is created. The method copies lastTick and delta directly and does not validate the input, so call Profile.validateSerial first when input is untrusted.

Parameters

NameDescriptionDefault
value

Serialized profile values.

—
out?

Profile to overwrite.

...

Returns

The populated profile.

staticvalidateSerial(value: unknown): value is ProfileSerial

View source

Checks whether a value has the shape required by Profile.deserialize.

The check requires a non-null object with numeric lastTick and delta properties. It accepts additional properties and does not impose ranges or reject NaN and infinities, because JavaScript classifies those values as numbers.

Parameters

NameDescriptionDefault
value

Value to check.

—

Returns

true when the required fields are numeric.