Created
September 15, 2016 14:27
-
-
Save jonekdahl/dc0d13b0a34c01bd711a8d7503ab69ca to your computer and use it in GitHub Desktop.
Test tool for host name resolution time in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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