Skip to content

Instantly share code, notes, and snippets.

View gabrielf's full-sized avatar

Gabriel Falkenberg gabrielf

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gabrielf on github.
  • I am gabrielf (https://keybase.io/gabrielf) on keybase.
  • I have a public key whose fingerprint is AF33 5EDB 691C 4CC8 FB2B 713A CCDE 7E0E 2A40 19DC

To claim this, I am signing this object:

This script will use the dns.lookup function, which is used by node internally when making http requests, to lookup an IP and a hostname 3 times. A healthy system should give output similar to:

lookup of 93.184.216.119: 0ms
lookup of 93.184.216.119: 0ms
lookup of 93.184.216.119: 0ms
lookup of example.com: 6ms
lookup of example.com: 1ms
lookup of example.com: 0ms

Note that the first hostname lookup took longer than the following because of caching in some DNS. An unhealthy system might give you output like this:

@gabrielf
gabrielf / lazy.js
Created March 22, 2013 13:16
Reformatted changes of https://github.com/pkrumins/node-lazy/pull/33/files to match the project's coding style.
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var stream = require('stream');
function Lazy(em, opts) {
if (!(this instanceof Lazy)) return new Lazy(em, opts);
EventEmitter.call(this);
var self = this;