environment | |
---|---|
OS | ArchLinux |
Mem | 16GB |
CPU | intel Core i7 8565U |
$ time node hoge
hello
!
world
node hoge 3.87s user 0.26s system 120% cpu 3.422 total
async function f() { | |
const p = new Promise(resolve => setTimeout(() => { | |
console.log("hello"); | |
resolve(); | |
}, 2000)); | |
for(let x = 0; x < 5000000; x++) { | |
setTimeout(() => {}, 10); | |
} | |
setTimeout(() => console.log("world"), 1000); | |
await p; | |
console.log("!"); | |
} | |
f() |