Created
March 16, 2019 20:59
-
-
Save hiranya911/a181db57b23d40106c92066546205d68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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