Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
Created March 11, 2011 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FGRibreau/865866 to your computer and use it in GitHub Desktop.
Save FGRibreau/865866 to your computer and use it in GitHub Desktop.
twitter stream sample api's simple benchmark
//https://github.com/jdub/node-twitter/
var twitter = require('twitter'),
sys = require('sys');
var twit = new twitter({
consumer_key: 'YOUR KEYS',
consumer_secret: 'YOUR KEYS',
access_token_key: 'YOUR KEYS',
access_token_secret: 'YOUR KEYS'
});
twit.stream('statuses/sample', onStream);
function onStream(stream){
stream.on('data', streamOnData);
};
var bench = {
started:false,
t:0
};
function streamOnData(tweet){
if(!bench.started){
bench.started = +new Date();
}
bench.t++;
if((+new Date() - bench.started) > 1000*60){
console.log('1min ' + bench.t + ' tweets soit ' + (bench.t/60) + ' tweets/sec');
bench.t = 0;
bench.started = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment