LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-04-2011, 12:17 PM   #1
ridoy
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;


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

// 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);
request.parse();


// create Response object

Response response = new Response(output);
response.setRequest(request);
response.sendStaticResource();


// Close the socket
socket.close();

}
catch (Exception e) {
e.printStackTrace();
continue;
}
}
}
}

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
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

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,

Eric
 
Old 04-14-2011, 03:05 AM   #3
ridoy
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.
 
  


Reply

Tags
java



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:09 PM.

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