let allCount = 3; let time1 = 0; let time2 = 0; function proTest() { console.log("pro...test"); test(); } function test() { setTimeout(() => { console.log('test...',allCount) if (allCount == 0) { time2 = new Date().getSeconds(); console.log(`运行时间${time2 - time1}秒`); return; } allCount--; proTest(); },1000 * allCount) } time1 = new Date().getSeconds(); proTest();