add profile for functions, profile CSS-es on startup, use __time

This commit is contained in:
Panayot Cankov
2017-05-25 13:05:14 +03:00
parent 35f0f73331
commit c519a4bb6f
5 changed files with 229 additions and 139 deletions

View File

@@ -20,8 +20,7 @@ export declare function enable(): void;
export declare function disable(): void;
/**
* Gets accurate system timestamp in ms.
* Works only if profiling is enabled.
* Gets accurate system timestamp in ms.
*/
export declare function time(): number;
@@ -61,6 +60,23 @@ export declare function isRunning(name: string): boolean;
* @param name Name of the timer which will be used for method calls. If not provided - the name of the method will be used.
*/
export declare function profile(name?: string): MethodDecorator;
/**
* Function factory. It will intercept the function call and start and pause a timer before and after the function call. Works only if profiling is enabled.
* Works only if profiling is enabled.
* @param fn The function to wrap. Uses the function name to track the times.
*/
export declare function profile<F extends Function>(fn: F): F;
/**
* Function factory. It will intercept the function call and start and pause a timer before and after the function call. Works only if profiling is enabled.
* @param name The name used to track calls and times.
* @param fn The function to wrap.
*/
export declare function profile<F extends Function>(name: string, fn: F): F;
/**
* Method decorator. It will intercept the method calls and start and pause a timer before and after the method call. Works only if profiling is enabled.
*/
export declare function profile<T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
export function profile(): any;
/**
* Prints the timer for all methods instrumented with profile decorator.
@@ -83,3 +99,8 @@ export declare function startCPUProfile(name: string): void;
* @param name Name of the cpu profiling session.
*/
export declare function stopCPUProfile(name: string): void;
/**
* Gets the uptime of the current process in miliseconds.
*/
export function uptime(): number;