I made an java app that gets a response time from the internet. I'm working from behind a proxy, now I have this problem that I can't figure out, here's a snipped of my code
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 a response time of 0.064 on average
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 is giving me an accurate timing?