定义一个测试函数,将待测函数作为参数传入
function test(func){
let start = new Date().getTime();//起始时间
func();//执行待测函数
let end = new Date().getTime();//接受时间
return (end - start)+"ms";//返回函数执行需要时间
}
定义一个测试函数,将待测函数作为参数传入
function test(func){
let start = new Date().getTime();//起始时间
func();//执行待测函数
let end = new Date().getTime();//接受时间
return (end - start)+"ms";//返回函数执行需要时间
}