Return to Snippet

Revision: 61321
at December 6, 2012 03:35 by trurl


Initial Code
var https = require('https')

function GetFBUser(x) {
  return { 
    host: 'graph.facebook.com',
    path: '/fql?' + encodeURI('q=select name from user where uid = ' + i)
  }
}

var N = process.argv.length > 2 ? process.argv[2] : 1000
loopme(N)

function loopme(n) {
  var done = 0
  var start = Date.now()
  for (var i = 0; i < n; i++) {
    https.get(GetFBUser(i), function(res) {
      // res.on('data', function(chunk) { console.log('BODY: ' + chunk) });
      res.on('end', function() { 
        if (++done == n) { 
          console.log(n + ',' + (Date.now() - start) / 1000.0) 
        }
      });
    });
  }
}

Initial URL

                                

Initial Description
// node stupidfb.js

Initial Title
stupid FB timing test with node

Initial Tags

                                

Initial Language
JavaScript