stupid FB timing test with node


/ Published in: JavaScript
Save to your folder(s)

// node stupidfb.js


Copy this code and paste it in your HTML
  1. var https = require('https')
  2.  
  3. function GetFBUser(x) {
  4. return {
  5. host: 'graph.facebook.com',
  6. path: '/fql?' + encodeURI('q=select name from user where uid = ' + i)
  7. }
  8. }
  9.  
  10. var N = process.argv.length > 2 ? process.argv[2] : 1000
  11. loopme(N)
  12.  
  13. function loopme(n) {
  14. var done = 0
  15. var start = Date.now()
  16. for (var i = 0; i < n; i++) {
  17. https.get(GetFBUser(i), function(res) {
  18. // res.on('data', function(chunk) { console.log('BODY: ' + chunk) });
  19. res.on('end', function() {
  20. if (++done == n) {
  21. console.log(n + ',' + (Date.now() - start) / 1000.0)
  22. }
  23. });
  24. });
  25. }
  26. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.