I made a java application that gets response time from the internet. I work because of the proxy server, now I have this problem that I can not understand, my code is disabled here
URL website = new URL("http", proxy, Integer.parseInt(proxyPort), websiteUrl)
BufferedReader in = new BufferedReader(new InputStreamReader(website.openStream()));
long start = System.currentTimeMillis();
while ((in.readLine()) != null){}
long elapsedTimeMillis = System.currentTimeMillis()-start;
Vs
URL website = new URL(websiteUrl);
System.setProperty("http.proxyHost", proxy);
System.setProperty("http.proxyPort", proxyPort);
BufferedReader in = new BufferedReader(new InputStreamReader(website.openStream()));
long start = System.currentTimeMillis();
while ((in.readLine()) != null){}
long elapsedTimeMillis = System.currentTimeMillis()-start;
When i use
URL website = new URL(websiteUrl);
System.setProperty("http.proxyHost", proxy);
System.setProperty("http.proxyPort", proxyPort);
I get an average response time of 0.064
and when i use
URL website = new URL("http", proxy, Integer.parseInt(proxyPort), websiteUrl)
I get a much higher response time of 0.219. How can I tell which one gives me the exact time?
Pim
source
share