: If you want to experiment, a really trivial test is below -- on my system,
: there is a ~5 second gap between each pair of "INIT" and "H1" timestamps,
: but no other odd gaps in subsequent timestamps -- suggesting no caching of
: DNS per hostname, but that the URL class doesn't "re-lookup" on subsequent
: hashCode() calls.
Or maybe i could actually cut & paste the test this time...
import java.net.URL;
import org.apache.lucene.util.LuceneTestCase;
public class TestURLDNSAbsurdity extends LuceneTestCase {
public void testHowSlowCanYouGo() throws Exception {
go("1");
go("2");
}
public void go(String s) throws Exception {
System.out.println(s + " PRE: " + System.currentTimeMillis());
URL url = new URL("http://example.com/");
System.out.println(s + "INIT: " + System.currentTimeMillis());
int h1 = url.hashCode();
System.out.println(s + " H1: " + System.currentTimeMillis());
int h2 = url.hashCode();
System.out.println(s + " H2: " + System.currentTimeMillis());
boolean e1 = url.equals(this);
System.out.println(s + " E1: " + System.currentTimeMillis());
boolean e2 = url.equals(this);
System.out.println(s + " E2: " + System.currentTimeMillis());
assertEquals(h1,h2);
assertEquals(e1,e2);
}
}
...
[junit4] Started J0 PID(31843@frisbee).
[junit4] Suite: org.apache.solr.util.TestURLDNSAbsurdity
[junit4] 1> 1 PRE: 1379107971313
[junit4] 1> 1INIT: 1379107971314
[junit4] 1> 1 H1: 1379107976449
[junit4] 1> 1 H2: 1379107976449
[junit4] 1> 1 E1: 1379107976449
[junit4] 1> 1 E2: 1379107976449
[junit4] 1> 2 PRE: 1379107976450
[junit4] 1> 2INIT: 1379107976450
[junit4] 1> 2 H1: 1379107981510
[junit4] 1> 2 H2: 1379107981510
[junit4] 1> 2 E1: 1379107981510
[junit4] 1> 2 E2: 1379107981510
[junit4] OK 10.3s | TestURLDNSAbsurdity.testHowSlowCanYouGo
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]