fix: more rollbacks

This commit is contained in:
Martin Guillon
2020-11-12 21:19:32 +01:00
parent b85d0e5ee3
commit 22e686d098

View File

@ -1,3 +1,4 @@
/* eslint-disable prefer-rest-params */
declare let __startCPUProfiler: any; declare let __startCPUProfiler: any;
declare let __stopCPUProfiler: any; declare let __stopCPUProfiler: any;
@ -98,10 +99,10 @@ export function isRunning(name: string): boolean {
function countersProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F { function countersProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F {
profileNames.push(name); profileNames.push(name);
return <any>function (...args) { return <any>function () {
start(name); start(name);
try { try {
return fn(...args); return fn.apply(this, arguments);
} finally { } finally {
stop(name); stop(name);
} }
@ -110,19 +111,19 @@ function countersProfileFunctionFactory<F extends Function>(fn: F, name: string,
function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F { function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F {
return type === MemberType.Instance return type === MemberType.Instance
? <any>function (...args) { ? <any>function () {
const start = time(); const start = time();
try { try {
return fn(...args); return fn.apply(this, arguments);
} finally { } finally {
const end = time(); const end = time();
console.log(`Timeline: Modules: ${name} ${this} (${start}ms. - ${end}ms.)`); console.log(`Timeline: Modules: ${name} ${this} (${start}ms. - ${end}ms.)`);
} }
} }
: function (...args) { : function () {
const start = time(); const start = time();
try { try {
return fn(...args); return fn.apply(this, arguments);
} finally { } finally {
const end = time(); const end = time();
console.log(`Timeline: Modules: ${name} (${start}ms. - ${end}ms.)`); console.log(`Timeline: Modules: ${name} (${start}ms. - ${end}ms.)`);