"use strict";
var handleChange = function handleChange(e) {
return function (dispatch) {
dispatch({
type: PROMO_CODE,
payload: e.target.value
});
};
};
var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
var t0, t1;
var results = [];
for (var i = 0; i < nTimes; i++) {
t0 = performance.now();
doSomething();
t1 = performance.now();
results.push(t1 - t0);
}
// если надо вывести результат
results.forEach(function(result, i) {
console.log('Call to doSomething #' + (i + 1) + ' took ' + result + ' milliseconds.');
});
Может я слишком часто отправляю ? Примерно 2-4 сообщения в 3 минуты. И отправляю 3-ем пользователям в цикле. Что я делаю не так ?
async function delayedPromise(cb) {
const delay = () => new Promise(resolve => setTimeout(resolve, 3000));
const result = await Promise.all([cb(), delay()]);
return result[0];
}
async function runPromisesInSequence(promises) {
for (let promise of promises) {
console.log(await delayedPromise(promise), new Date());
}
}
const pr1 = () => new Promise(res => setTimeout(() => res('r1'), 1000));
const pr2 = () => new Promise(res => setTimeout(() => res('r2'), 5000));
const pr3 = () => new Promise(res => setTimeout(() => res('r3'), 0));
const y = [pr1, pr2, pr3];
runPromisesInSequence(y);
const pr1 = new Promise(res => setTimeout(() => res('r1'), 1000));