c# - Equivalent java code to measure response time of server -
what equivalent java api s should using following c# code please? need check response time.
httpwebrequest request = (httpwebrequest)webrequest.create(address); system.diagnostics.stopwatch timer = new stopwatch(); timer.start(); httpwebresponse response = (httpwebresponse)request.getresponse(); timer.stop(); timespan timetaken = timer.elapsed;
thanks in advance.
try:
long start = system.currenttimemillis(); //dosth. long elapsed = system.currenttimemillis() - start;
for more precision use system.nanotime()
returns nano seconds between 2 calls. note this: this method provides nanosecond precision, not nanosecond accuracy.
a simple way read url , measure speed might be:
long start = system.currenttimemillis(); url url = new url(urlstring); url.getcontent(); long elapsed = system.currenttimemillis() - start;
Comments
Post a Comment