Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:44:00+00:00 2026-05-31T23:44:00+00:00

I have been testing the performance of reading server socket input stream. I found

  • 0

I have been testing the performance of reading server socket input stream. I found that reading itself has about ~9000 nano second (9 us) delay. How can I improve its performance?
I have tried JAVA default buffer size and something a bit bigger than that. But its performance is not much changed. In this case, I counted every 1600 samples from the client.

Most delay is found in this line:

inputLine = in.readLine();

Here is the code of reading thread:

PrintWriter out = new PrintWriter(door.getOutputStream(), true);            
BufferedReader in = new BufferedReader(new InputStreamReader(door.getInputStream()), 10240);           

File file = new File(this.storageDirectory);
BufferedWriter save = new BufferedWriter(new FileWriter(file));

String inputLine = null;

while(Switch)
{
    inputLine = in.readLine(); //I found ~9000 ns delay in this line.
    save.write(inputLine);


    if(iCounter==0)
        StartTime = System.nanoTime();                   

    iCounter++;                      


    if(iCounter>=1600) //need to store them.
    {
        EndTime = System.nanoTime();
        TimeTick = (EndTime - StartTime)/1600;
        System.out.println("TimeTick is [ns]: " + TimeTick);                    
        iCounter = 0;
    }
 }

Here is the result:

TimeTick is [ns]: 9241
TimeTick is [ns]: 9941
TimeTick is [ns]: 6535
.....

Here is the result without ‘inputLine = in.readLine();’

TimeTick is [ns]: 0
TimeTick is [ns]: 0
TimeTick is [ns]: 1
......

How can I improve reading performance? The client is just sending random double point values upon request.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:44:01+00:00Added an answer on May 31, 2026 at 11:44 pm
    String inputLine = null;
    
    while (...) {
        ...
        inputLine = in.readLine(); //I found ~9000 ns delay in this line.
        save.write(inputLine);
        ...
    }
    

    If you comment out the read line, you’ll have nothing to write, so in effect you’re commenting out both lines, no?

    Your micro-benchmarks (which seem a bit dodgy to begin with) would probably reveal better information if you had some default string which save.write wrote in each iteration.

    Good and relevant question and answer:

    • How do I write a correct micro-benchmark in Java?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET 3.5 server application that usually has about 8 clients. I'm
As I have been testing sites, I have found reCAPTCHA s getting more and
I have been hearing that with unit testing we can catch most of the
I've been trying to implement unit testing and currently have some code that does
I have been tasked with looking for a performance testing solution for one of
I have made a TCP server which I have been testing locally and it
I have been doing some unsafe bitmap operations and have found out that increasing
We have an application that is undergoing performance testing. Today, I decided to take
I have been testing and playing around with jquery date picker below. http://jqueryui.com/demos/datepicker/ on
I have been using CPPUnit as a unit testing framework and am now trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.