const randomDelay = () => new Promise(resolve => setTimeout(resolve, Math.random()*1000));
(async function() {
let counter = 0;
while (true) {
console.time('timer');
await randomDelay();
console.timeEnd('timer');
if (counter++ > 20) {
break;
}
}
})();