1 2 Previous Next 23 Replies Latest reply: Dec 6, 2012 1:07 PM by aksarben RSS

    Java Running Program Slower Than Partner

    976525
      I have a very peculiar issue with a program I've made for a class. We were allowed to work with a partner on this project, and I was optimizing the code to make it run faster. I got to a certain point where I couldn't think of anything else to do, and it was running at about 2.5 seconds. I added it to Dropbox for my partner to download and check out, and when he ran it, he got a time of 0.5 seconds. Same exact code.

      We've tried a few things such as re-uploading from both ends to see if there was some difference. I've re-installed eclipse and tried a different version and re-installed the latest JDK. I downloaded the Eclipse IDE for Java developers. That didn't solve the issue. So then I tried compiling the program with javac from the command prompt and running the program that way. This still gave me a time of around 2.5 seconds. I ran the Windows Experience index to see if my computer could have something wrong with it, but it came up with numbers slightly better than before. So it can't be anything wrong with my actual system. I haven't noticed a decrease in performance. So this narrows everything down to the Java environment itself.

      We know the program works. It's already been submitted, graded, and returned and like I said, it runs extremely efficiently on my partner's computer. I just can't think of ANY REASON at all this program is running more slowly on my computer. Have any of you encountered an issue like this? I don't want anything to plague me for future projects.

      Thanks for any ideas or assistance!
      -Cole
        • 1. Re: Java Running Program Slower Than Partner
          gimbal2
          Really? You can't think of anything?

          - slower computer hardware
          - worse IO performance
          - malware / virus / etc.
          - more running processes
          - patch state of the OS
          - different version of the Java runtime
          - the position of the stars
          etc.
          • 2. Re: Java Running Program Slower Than Partner
            976525
            This is basically a brand new computer I'm using and my partner is using a Mac. There's no reason why I should be getting that big of a difference in run time. I have better components in my computer. That's the only process running. And I have the LATEST version of Java.

            And the position of the stars are aligned just right in case you were wondering.

            Any other ideas?
            • 3. Re: Java Running Program Slower Than Partner
              DrClap
              973522 wrote:
              This is basically a brand new computer I'm using and my partner is using a Mac.
              You haven't said anything about the differences between the two computers. Even that statement is incomplete because it doesn't say whether your computer is a Mac or not.
              There's no reason why I should be getting that big of a difference in run time.
              Sure there is. I can say that with confidence because you are indeed getting that big of a difference. But from what you've said there is no way for us to tell what that reason is. For all we know your partner might just be clicking the stopwatch faster than you, or measuring the time differently.

              Now you're going to come back and say that there's no stopwatches involved and that the timing is built into the program. Or something like that. My point is, so far you haven't given us any information except that the measured time is different in two places.
              • 4. Re: Java Running Program Slower Than Partner
                DrClap
                Actually... I see clues that you aren't using a Mac from your first post. So it turns out that the two computers are quite different. In particular they are using different Java runtimes.

                So perhaps the Windows runtime starts up slower than the Mac's runtime does. Or perhaps your timing doesn't include the startup time for the runtime -- we're back into the no-information zone.
                • 5. Re: Java Running Program Slower Than Partner
                  gimbal2
                  Except for the stars joke all I said can be a factor. Computers are like snow flakes anyway; you can buy two identical Dell systems in the same serial number range and still get different results.

                  But it seems that you are dealing with two completely different systems altogether (Mac and something else), so I really don't get why you are mystified. The computers are woefully different, there is no mystery to solve here.
                  • 6. Re: Java Running Program Slower Than Partner
                    976525
                    The fact that run times were supposed to be a target of around 0.5 seconds for this project is just what concerns me. Other people have achieved that time. Obviously their code is different, but the point I was trying to get across is that I wouldn't be concerned if it were a decimal difference. What concerns me is that it's seconds. You're correct. I'm using an Alienware computer and my partner has the Mac, but the difference should never be that huge. It only gets worse as we try to run more data.

                    The timer, like you suspected, is clocked from the system timer Java uses. We get the time when it begins and ends and subtract the difference. This is built into the program's main and is printed into an output file at the end.

                    I understand the thought that the systems are completely different, and I wouldn't be so worried if it were not for the comparison of data with our computers and other classmates. We have statistics other than time from the program that line up with the numbers we should expect based on the professor's approval of students output. So when those statistics are the same and the ONLY difference is the run time, that's what concerns me. And I know it's not an issue of the timer being started incorrectly because you can easily see the difference in performance when ran.

                    Obviously this won't mean much, but just note as the numbers increase, so do the time differences. However, the statistics are relatively the same. (The files are generated randomly)
                    Here's some sample data:

                    Partner's Output:
                    bin20.txt, with 20 blocks and 10 buffers...
                    Cache hits: 1398437
                    Cache misses: 9973
                    Disk reads: 9973
                    Disk writes: 9310
                    Run time: 536ms

                    My Output:
                    bin20.txt, with 20 blocks and 10 buffers...

                    Cache hits: 1397557
                    Cache misses: 9986
                    Disk reads: 9986
                    Disk writes: 9307
                    Run time: 7667ms

                    Partner's Ouput:
                    bin10.txt, with 10 blocks and 5 buffers...
                    Cache hits: 647388
                    Cache misses: 5866
                    Disk reads: 5866
                    Disk writes: 5462
                    Run time: 315ms

                    My Output:
                    bin10.txt, with 10 blocks and 5 buffers...

                    Cache hits: 646955
                    Cache misses: 5891
                    Disk reads: 5891
                    Disk writes: 5449
                    Run time: 4558ms

                    Hopefully this information helps clear up some things. Again, I'm just kind of baffled about this, and I don't think it's simply a problem of having different systems.
                    • 7. Re: Java Running Program Slower Than Partner
                      baftos
                      Your program seems to be file IO oriented. Do you have a real-time anti-virus? Try to disable it, just as an experiment. Look carefully at the differences when it comes to hard-disk quality (SSD one of you?).

                      Edited by: baftos on Nov 27, 2012 9:41 PM
                      • 8. Re: Java Running Program Slower Than Partner
                        976525
                        The program doesn't actually go into the hard disk of the computer. It's just a simulation of reading from cache and disk. We give it a binary .txt file and that is simulated as the disk. From there it manages its own cache with a linked list and performs the necessary operations. Neither me or my partner have an SSD.
                        • 9. Re: Java Running Program Slower Than Partner
                          rp0428
                          >
                          I don't think it's simply a problem of having different systems.
                          >
                          Really? Everything you've posted seems to indicate that is exactly the problem. You said the source code is the same but you haven't posted it so we can see what it is doing.

                          You also haven't posted any information about what versions of Java are being used to compile the code, what the target Java version is, what Java version is being used to execute the code, how the code is being executed (command-line, IDE, etc). You haven't said much of anything except that the code is the same but you don't think the different systems enter into the picture.

                          So prove your statment by doing several other things (e.g. copying a large file) on both systems and timing them to see how long it takes. Create a loop in Java that iterates several million times and see how long it takes on each system.

                          You need to actually do some test to see if the different systems come into play you can't just say you don't think they do. That isn't troubleshooting, that is just wishful thinking.
                          • 10. Re: Java Running Program Slower Than Partner
                            gimbal2
                            rp0428 wrote:
                            You need to actually do some test to see if the different systems come into play you can't just say you don't think they do. That isn't troubleshooting, that is just wishful thinking.
                            Yeah!
                            • 11. Re: Java Running Program Slower Than Partner
                              Tolls
                              973522 wrote:
                              The program doesn't actually go into the hard disk of the computer. It's just a simulation of reading from cache and disk. We give it a binary .txt file and that is simulated as the disk. From there it manages its own cache with a linked list and performs the necessary operations. Neither me or my partner have an SSD.
                              Is the reading of the file included in the timings?

                              I would consider the granularity of currentTimeMillis as well between the systems, though you say you take a timestamp at the start of running and at the end, so that's possibly an unlikely source.
                              • 12. Re: Java Running Program Slower Than Partner
                                976525
                                No. The reading of the file is separate. Only the algorithm and calculations are timed. We both copied a large file. Mine executed more quickly. However, I made 3 tests in Java. In one, I printed a word a million times. In another, printed, and then calculated pi/4 a billion times. In the last test, I included the System.currentTimeMillis().

                                What we discovered is that my partner's prints finished way before mine (at least 1.5 seconds), however during the calculation, mine caught up a significant amount and only finished a split second afterwards. So I then tried commenting out the system functions in our project, but to no avail. My project still ran poorly.

                                I don't mean to be a nuisance, but I'm just concerned with the fact that my computer seems to be performing poorly in java. I've ran Intel processor diagnostics that pass fine. My computer runs games smoothly. I know it's extremely difficult to come to any conclusion without being able to see everything, but I'm really just stuck. My computer's performance does not seem to be affected, as far as I can tell.
                                • 13. Re: Java Running Program Slower Than Partner
                                  rp0428
                                  >
                                  tried a different version and re-installed the latest JDK
                                  . . .
                                  So then I tried compiling the program with javac from the command prompt
                                  . . .
                                  And I have the LATEST version of Java
                                  . . .
                                  However, I made 3 tests in Java
                                  . . .
                                  Again, I'm just kind of baffled about this
                                  . . .
                                  my computer seems to be performing poorly in java
                                  >
                                  You keep mentioning Java. But do you see ANYTHING in what you posted that even mentions what version of Java is being used on each of the machines? Or ANYTHING about how each of those versions of Java are configured? Or ANYTHING about the command-line parameters that might indicate the amount of memory being made available, whether client or server jvms are being used or the like?

                                  Let's review what some of the responders have mentioned to you

                                  Well gimbal2 said
                                  >
                                  Really? You can't think of anything?
                                  . . .
                                  - different version of the Java runtime
                                  >
                                  DrClap said
                                  >
                                  In particular they are using different Java runtimes.
                                  >
                                  I said
                                  >
                                  You also haven't posted any information about what versions of Java are being used to compile the code, what the target Java version is, what Java version is being used to execute the code, how the code is being executed (command-line, IDE, etc).
                                  >
                                  The very last thing you said was
                                  >
                                  my computer seems to be performing poorly in java
                                  >
                                  So can you explain why you still haven't

                                  1. posted ANY information about the versions of Java being used on each machine

                                  2. executed any tests on your machine that use EXACTLY the same version of Java that the other machine is using.

                                  You keep mixing pears, grapes, cherries, peaches and pineapple and wondering why you keep getting fruit cocktail.

                                  You need to compare apples to apples, oranges to oranges, etc to etc.

                                  The sooner you start doing that the sooner you will make progress.
                                  • 14. Re: Java Running Program Slower Than Partner
                                    976525
                                    If I have the latest version of Java, why would it matter what my partner has if his program is executing more quickly than mine? Unless Java managed to make a less efficient update.

                                    To be specific, my version of java is 1.7.0_09 and my partners is 1.7.0_06. So yes, the update version is different, but it shouldn't matter unless Java's new version somehow doesn't work as efficiently.
                                    1 2 Previous Next