PrivateconstructorPrivate constructor to enforce singleton pattern. Initializes the store for profiler entries.
Optionalactive: boolean = falseOptional parameter to enable the profiler
PrivateactiveOptional parameter to enable the profiler
Private OptionallastPrivatememPrivatenowPre-computed functions for time and memory retrieval
Returns the services provided by the Profiler class. This allows for easy access to the profiler's methods.
PrivatestoreStore for profiler entries
PrivatetotalPrivatetotalTotal time and memory consumption
Private StaticENVEnvironment detection
Private StaticinstanceSingleton instance
Resets the profiler by clearing the store, total time and memory consumption. This method is useful for starting a new profiling session.
Disables the profiler. Sets the active state to false, preventing further profiling.
Enables the profiler. Sets the active state to true, allowing profiling to occur.
Retrieves all profiler entries stored in the profiler.
Retrieves the last profiler entry stored in the profiler.
Retrieves the total time and memory consumption recorded by the profiler.
Runs a synchronous function and profiles its execution time and memory usage. If the profiler is not active, it simply executes the function without profiling.
Function to be executed and profiled
Metadata to be associated with the profiling entry
Runs an asynchronous function and profiles its execution time and memory usage. If the profiler is not active, it simply executes the function without profiling.
Asynchronous function to be executed and profiled
Metadata to be associated with the profiling entry
PrivatestoreStores a profiler entry in the store and updates the total time and memory consumption.
The profiler entry to be stored
Protected StaticdetectSets the environment based on the available global objects. Detects if running in Node.js or browser and sets the ENV property accordingly.
StaticgetReturns the singleton instance of the Profiler class. If the instance does not exist, it creates a new one.
Optionalenable: booleanOptional parameter to enable the profiler upon instantiation
Profiler class for measuring execution time and memory usage of functions.