Skip to content

Instantly share code, notes, and snippets.

@smurfpandey
Forked from argon/apn-bench.js
Last active August 29, 2015 14:23
Show Gist options
  • Save smurfpandey/e65fb82da3a31f5683f3 to your computer and use it in GitHub Desktop.
Save smurfpandey/e65fb82da3a31f5683f3 to your computer and use it in GitHub Desktop.
var apn = require('apn');
var token = "<token here>";
var service = new apn.connection({
maxConnections: 1
});
service.on("completed", function() { console.log("Completed!")});
service.on("connected", function() { console.log("Connected"); });
service.on('disconnected', function() { console.log("Disconnected", arguments); });
service.on('error', function(err) { console.log("Standard error", err); });
service.on('socketError', function(err) { console.log("Socket error", err.message); });
service.on('timeout', function() { console.log("Timeout"); });
service.on('transmissionError', function(err) { console.log("Transmission Error", err); });
var total = 0;
service.on("transmitted", function(notification) {
if(total === 0) {
console.time("notifications");
}
if(total === count - 1) {
console.timeEnd("notifications");
}
total++;
});
var count = 10000;
var note = new apn.notification();
for (i=0; i < count; i++) {
note.badge = 1;
service.pushNotification(note, token);
}
service.shutdown();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment