1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 5x 5x 5x 5x 5x 9x 9x 9x 9x 9x 9x | import * as Debug from 'debug';
const debug = Debug('overland:core');
export default function timer(event: string = 'tim') {
return function(target, key, descriptor) {
return {
value: async function(...args: any[]) {
debug(`${ event }ing`);
const boot = process.hrtime();
const res = await descriptor.value.apply(this, args);
const [ , ns ] = process.hrtime(boot);
debug(`${ event }ed (took ${ (ns / 1000000).toFixed(3) } ms)`);
return res;
}
};
};
};
|