a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / MeasureTime
MeasureTime(
_target
,propertyKey
,descriptor
):void
A decorator that measures the execution time of a method.
The @MeasureTime
decorator wraps a method, logging the time it takes to execute in milliseconds.
This can be useful for performance profiling and identifying slow methods.
• _target: unknown
The target object that owns the method.
• propertyKey: string
The name of the method being decorated.
• descriptor: PropertyDescriptor
The method descriptor, which provides access to the method itself.
void
A function that can be used as a method decorator.
class ExampleClass {
@MeasureTime
processData(data: string): string {
// Simulate some processing time
for (let i = 0; i < 1e6; i++) {
}
return `Processed ${data}`;
}
}
const example = new ExampleClass();
example.processData('test');
// Logs:
// [processData] Execution time: 123.456ms