Skip to content

Instantly share code, notes, and snippets.

@jonekdahl
Created September 15, 2016 14:27
Show Gist options
  • Select an option

  • Save jonekdahl/dc0d13b0a34c01bd711a8d7503ab69ca to your computer and use it in GitHub Desktop.

Select an option

Save jonekdahl/dc0d13b0a34c01bd711a8d7503ab69ca to your computer and use it in GitHub Desktop.
Test tool for host name resolution time in Java
#!/usr/bin/env jjs
var lookup = function(host) {
var start = java.lang.System.currentTimeMillis();
try {
//new java.net.InetSocketAddress(host, 47100);
java.net.InetAddress.getAllByName(host);
} catch (e) {
print(e);
}
var time = java.lang.System.currentTimeMillis() - start;
print('Resolution of "' + host + '" took ' + time + ' ms');
}
if ($ARG.length === 0) {
print("Usage: jjs -scripting resolv.js -- <hostname>");
} else {
lookup($ARG[0]);
}
// Create file on server
// # cat > resolv.js <<"EOF"
// <paste source above>
// EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment