Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-04-2011, 12:17 PM   #1
LQ Newbie
Registered: Feb 2011
Posts: 19

Rep: Reputation: 1
Unhappy measuring server-side response time

This is my server code:

class Server extends Thread
/* WEB_ROOT is the directory where HTML and other files reside.
public static final String WEB_ROOT =
System.getProperty("user.dir") + File.separator + "content";

// shutdown command
public static final String SHUTDOWN_COMMAND = "/SHUTDOWN";

// the shutdown command received
public boolean shutdown = false;
ServerSocket serverSocket;
Socket socket;
InputStream input;
OutputStream output;

public void run()
serverSocket = null;
int port = 8080;
try {
serverSocket = new ServerSocket(port, 1, InetAddress.getByName(""));
catch (IOException e) {

// Loop waiting for a request
while (!shutdown)
try {
socket = serverSocket.accept();
input = socket.getInputStream();
output = socket.getOutputStream();

// create Request object and parse

Request request = new Request(input);

// create Response object

Response response = new Response(output);

// Close the socket

catch (Exception e) {

I want to measure it's response time.One idea is to use System.currentTimeMillis() method.But is this good enough to output my server response time? Anyone have idea how to do this?
Thanks for any help..
Old 04-13-2011, 02:25 AM   #2
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295

You marked your thread as SOLVED. Would you mind sharing what you've found that solves your problem so that others in the same situation might see if it works for them.

Kind regards,

Old 04-14-2011, 03:05 AM   #3
LQ Newbie
Registered: Feb 2011
Posts: 19

Original Poster
Rep: Reputation: 1
Of course..why not? For solving my problem i use System.currentTimeMillis() method.I call the response object between two time variables.Then the difference of two times indicates the response time of server.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Measuring boot time kushalkoolwal Linux - Software 4 03-19-2009 03:11 PM
Measuring Time Complexity on C++ vxc69 Programming 1 02-18-2008 01:05 PM
measuring time in linux (in C) Four Programming 4 12-30-2005 09:21 PM
time out while wating for response from smtp server robmainella Linux - Software 0 09-07-2003 08:22 PM
measuring time Hano Programming 2 04-21-2002 12:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration