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 6473741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:30:10+00:00 2026-05-25T06:30:10+00:00

When I execute the simple code sample below via Eclipse (version 3.5.2, on Ubuntu

  • 0

When I execute the simple code sample below via Eclipse (version 3.5.2, on Ubuntu 10.04, java version “1.6.0_20”
OpenJDK Runtime Environment (IcedTea6 1.9.9) (6b20-1.9.9-0ubuntu1~10.04.2)
OpenJDK Server VM (build 19.0-b09, mixed mode)), it takes about 10 seconds. When I execute it from my shell (using the same priority and java version), it takes about 40 seconds.

for (int i = 0; i<1000*1000; i++) {
  System.out.println(Math.cos(i));
}

I also tried other programs, varying in runtime and amount of output: Each one was much slower in the shell. This was independent of the order of execution. The minimum percentage difference was 85 seconds in Eclipse vs. 145 seconds in shell for a program with very little output.

What’s the reason?

  • 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-25T06:30:11+00:00Added an answer on May 25, 2026 at 6:30 am

    It’s because you’re timing your terminal. Some terminals are just bog-slow when displaying/scrolling text. And your terminal is line buffered, vs the eclipse console likely have more buffering – leading to your program having to wait for your terminal after every line it prints.

    Try redirecting the output of your program to a file or /dev/null, and time it.

    On my system this makes a bit difference with your little loop:

    $ time java T
     --snip - 1M lines of output--
    
    real    0m24.746s
    user    0m2.403s
    sys     0m1.597s
    
    $ time java T >output
    
    real    0m5.172s
    user    0m2.800s
    sys     0m2.707s
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use Amazon-SDK(Java) sample code S3TransferProgressSample.java to upload large files to Amazon-S3
Below is my simple asp code that I am using to insert some data
My code below is a simple Titanium mobile application for Android. I implemented database
Background Below is a typical piece of Perl code ( sample.pl for the sake
I'm trying to do something simple here. When I execute the following code in
The following code executes a simple insert command. If it is called 2,000 times
Simple sum of digits code. It compiles but when executed, the last cout gives
I am trying to get simple jQuery to execute on my Content page with
In my simple custom shell I'm reading commands from the standard input and execute
The following simple query takes a very long time (several minutes) to execute. I

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.