Function logRunTime

  • 打印某个函数运行时间

    Parameters

    • fn: any

      方法函数

    • timeKey: string

      打印时间记录关键 key

    Returns void

    logRunTime(() => [1, 2, 3].reduce(...));
    logRunTime(() => [1, 2, 3].reduce(...), 'timeKey');
    logRunTime(async () => { await fun1(); await fun2(); });
    logRunTime($promiseReturnFunction);
    logRunTime(new Promise((resolve, reject) => { setTimeout(() => resolve('test'), 1000) }));