refactor: measurecTime添加函数值
This commit is contained in:
parent
26c776c3f4
commit
57e41364d9
@ -59,7 +59,7 @@ export function swap(array, a, b) {
|
|||||||
const startTime = performance.now();
|
const startTime = performance.now();
|
||||||
|
|
||||||
// 执行传入的函数,使用 apply 或 call 传入参数
|
// 执行传入的函数,使用 apply 或 call 传入参数
|
||||||
func(...args);
|
const result = func(...args);
|
||||||
|
|
||||||
// 计算函数执行所花费的时间
|
// 计算函数执行所花费的时间
|
||||||
const endTime = performance.now();
|
const endTime = performance.now();
|
||||||
@ -67,6 +67,7 @@ export function swap(array, a, b) {
|
|||||||
|
|
||||||
// 打印执行时间
|
// 打印执行时间
|
||||||
console.log(`Function execution time: ${elapsedTime} milliseconds`);
|
console.log(`Function execution time: ${elapsedTime} milliseconds`);
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user