Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created March 16, 2019 20:59
Show Gist options
  • Save hiranya911/a181db57b23d40106c92066546205d68 to your computer and use it in GitHub Desktop.
Save hiranya911/a181db57b23d40106c92066546205d68 to your computer and use it in GitHub Desktop.
function getMessages(count) {
const messages = [];
for (let i = 0; i < count; i++) {
messages.push({
topic: `test-topic-${i % 10}`,
});
}
return messages;
}
async function testSend() {
const messages = getMessages(1000);
const start = Date.now();
const promises = [];
for (let i = 0; i < messages.length; i++) {
promises.push(admin.messaging().send(messages[i]));
}
await Promise.all(promises);
return Date.now() - start;
}
async function testSendAll() {
const messages = getMessages(1000);
const start = Date.now();
const promises = [];
for (let i = 0; i + 100 <= messages.length; i += 100) {
const batch = messages.slice(i, i + 100);
promises.push(admin.messaging().sendAll(batch));
}
await Promise.all(promises);
return Date.now() - start;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment