This commit is contained in:
vakrilov
2017-05-12 17:22:00 +03:00
parent 08db23d613
commit 7e3fdb4505
2 changed files with 5 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ export declare function stop(name: string): TimerInfo;
* Works only if profiling is enabled.
* @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): (target, key, descriptor) => void;
export declare function profile(name?: string): MethodDecorator;
/**
* Prints the timer for all methods instrumented with profile decorator.

View File

@@ -49,9 +49,8 @@ export function start(name: string): void {
return;
}
let info: TimerInfo;
if (timers.has(name)) {
info = timers.get(name);
let info = timers.get(name);
if (info) {
if (info.isRunning) {
throw new Error(`Timer already running: ${name}`);
}
@@ -107,11 +106,10 @@ function pauseInternal(name: string): TimerInfo {
return info;
}
export function profile(name?: string): (target, key, descriptor) => void {
export function profile(name?: string): MethodDecorator {
return (target, key, descriptor) => {
if (!ENABLED) {
// Return the original descriptor if not enabled
return descriptor;
return;
}
// save a reference to the original method this way we keep the values currently in the