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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:54:03+00:00 2026-06-18T10:54:03+00:00

I have written a simple SUDOKU solver. To roughly test the performance I’m using

  • 0

I have written a simple SUDOKU solver. To roughly test the performance I’m using simple System.currentTimeMillis calls.

I have prepared a set of initial sudoku configuration in text file. The program reads the file and solves each sudoku configuration. When running the tests I have noticed that the first 3-4 solve runs are really slower than the rest and by slower I mean by order of magnitude.

There is sample pseudo-code snippet:

main(){
     while(file has lines){
         configuration = readLine();
         Solver s = new Solver(configuration);

         now1 = System.currentTimeMillis();
         s.solve();
         now2 = System.currentTimeMillis();

         System.out.print(now2 - now1);
     }
}

I measure only solve() method, so IO is not a problem, I even hardcoded some data into program – still first few slower. The difficulty of puzzle is not an issue as well I have tried different permutations and difficulties of configuration and always the same – first few are slower.

My question is – why is that and is there a way to prevent it?

  • 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-06-18T10:54:05+00:00Added an answer on June 18, 2026 at 10:54 am

    This is supposed to happen. The JIT compiler optimizes code that gets called more often as your program runs for longer.

    This only reflects the general fact that the technique you’re using to test performance simply isn’t reliable in Java.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple test application using asp.net mvc with C#. The application
I have written some simple code, to send en auto generated email, using the
I have written a simple test application (Mac/Cocoa) to connect to the Key-Value store
I have written a simple test class for Play! 2.0: public class TestLogin {
I have written a simple ftp uploader in C++ with qt using QNetworkAccessManager's put
I have written a simple SSL Client/Server set of programs from a few tutorials
I have written simple first stage bootloader which displays Hello world using interrupt to
I have written a simple forum in PHP using PostgreSQL. The forum consists of
i have written a simple code to display an image using Jsp XHTML template
I have written simple code to determine country location using the suffix on the

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.