当前位置: 动力学知识库 > 问答 > 编程问答 >

sockets - Measure DNS-Lookup time with java

问题描述:

I need to measure DNS Lookup time out of a java application. My idea is to measure the execution-time of InetAddress.getByName("myName"). What I'm not sure about is if this call is cached by operating-system. Can anybody tell me if so?

Is there maybe a better way to do that?

网友答案:

I am not sure about the Operating System but Java has its own DNS cache which are configurable via system properties. Please checkout this link for more details.

EDIT:

Your use case warrants disable DNS caching.

网友答案:

Regarding caching, the javadoc of InetAddress says that:

The InetAddress class has a cache to store successful as well as unsuccessful host name resolutions. 

So whatever about the OS, Java caches the results.

Read on, and you can see JVM args you can specify to modify the default caching behaviour.

分享给朋友:
您可能感兴趣的文章:
随机阅读: