Page 3 of 3 FirstFirst 123
Results 41 to 53 of 53
Like Tree5Likes

Thread: Why does Java process things very long?

  1. #41
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,037
    Rep Power
    10

    Default Re: Why does Java process things very long?

    Quote Originally Posted by gimbal2 View Post
    I'm glad we agree, we Dutch people need to stick together still being a minority in this forum ;)
    I'm Pennsylvania Dutch, does that count?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  2. #42
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Why does Java process things very long?

    Please make it clear, I don't know what you want me to do.

  3. #43
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,346
    Rep Power
    6

    Default Re: Why does Java process things very long?

    Quote Originally Posted by KevinWorkman View Post
    I'm Pennsylvania Dutch, does that count?
    Yeah sure!

    Quote Originally Posted by Tawi View Post
    Please make it clear, I don't know what you want me to do.
    I suggest you read the entire thread again then, because you've been given plenty of help already. If even all that can't help you... well I certainly hope that's not the case.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #44
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Why does Java process things very long?

    Try what Kevin suggested in post#23.

    Also try the java command's -Xprof option
    If you don't understand my response, don't ignore it, ask a question.

  5. #45
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Why does Java process things very long?

    Look, you want me to put the counting lines, done, you want me to break it up, done, so? The problem is not solved, how to solve the problems? Just please activate the link and download the files please! I do not know the things I need to do.

  6. #46
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,037
    Rep Power
    10

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    Please make it clear, I don't know what you want me to do.
    I'll collect all of the advice you've received here:

    Try to make a small program that compiles, executes and shows the problem.
    ANother option would be to profile the program to see where it spends its time. The java command has the -Xprof option.
    Whenever you have a question about a program, it's best to present it in the form of a SSCCE. Often you will figure out the answer yourself in the process of writing the SSCCE.
    You need to identify the algorithms the program is using and determine their time complexity.
    If you want free help, write a SSCCE.
    use a profiler tool to find what code is taking so long to process. Eclipse has one built in I believe, never really needed one for actual execution speed (only for memory consumption, for which I use JVisualVM).
    OP's next step is to figure out which part of the program is taking up most of the time. This can be done with some pretty simple profiling, just print statements showing how long each part of the program took. When the OP has it narrowed down to a single function (or maybe a single for loop or if statement), then he can create an SSCCE showing the code that's taking a long time. When we see the SSCCE, we can suggest ways to improve the code performance.
    You need to narrow your problem down. What part of your program is taking a long time? You mentioned that your program is doing some calculations. Which *part* of those calculations is taking a long time?

    One of the simplest ways to figure this out is to add print statements that time the different parts of your program. Something like this:

    Java Code:
    long start = System.currentTimeMillis();
    //do part one
    long elapsed = System.currentTimeMillis() - start;
    System.out.println("Part one took: " + elapsed);
     
    start = System.currentTimeMillis();
    //do part two
    elapsed = System.currentTimeMillis() - start;
    System.out.println("Part twotook: " + elapsed);
     
    start = System.currentTimeMillis();
    //do part three
    elapsed = System.currentTimeMillis() - start;
    System.out.println("Part threetook: " + elapsed);
    Using this approach you can figure out which part of the program is taking a long time. For example, maybe my above code tells me that part one takes 1 second, part two takes 45 seconds, and part three takes 2 seconds. That tells me that my problem is in part two, and I can ignore parts one and three for now. Then you can repeat that process inside part two: which part of it is taking a long time?

    This is what we mean when we say you need to isolate the problem. There really isn't much else we can do until you narrow your problem down further.
    There must be loops or calls to methods the you can use the end time minus start time computations that Kevin suggested to isolate where time is being spent. Its an iterative process. Try here, try there. As you find areas that take time, go into them and add more end-start time measures.
    What exactly does the button do? Split that up into two halves, timing each half like I showed you. Does one half take significantly longer? If so, split that half into to halves again, and repeat the process until you have your problem narrowed down to just a few lines. If you're still not sure why those few lines take so long, post them here in the form of an SSCCE and we'll be glad to help.
    You have to learn how to isolate your code. This is programming 101. If the login has nothing to do with the problem, then for your test purposes, hardcode the login information that's required by the next piece. Have you tried timing different parts of your program yet? Which part takes the longest? Have you tried timing the different parts of that part?
    Which *part* of the process takes that long?
    One word: profiler. (Shameless plug) I spent 400 euros on JProfiler and never looked back at petty performance problems. The information you get is priceless. Or find a free one. I don't care.

    The sentence "I have performance issues" should be followed by the sentence "I will start my profiler now". If that shows some code that you don't know how to get faster, then by all means, show it to us in the dreaded SSCCE, and we can help.
    You haven't replied to any of this advice other than to beg us to look at your entire program. That isn't how this works. Please see the link in my signature on asking questions the smart way before you post again.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #47
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Why does Java process things very long?

    I did all of it. It is not possible to break it or teach me how by seeing my program, will you? give me the example about the technique to use the +xprof. It is an integrated program. How?

  8. #48
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default Re: Why does Java process things very long?

    Here is a sample of using the java command's -Xprof option:
    Java Code:
    D:\Java\jdk1.7.0_45\bin\java.exe -Xprof -cp . WakeOnLan
    
    .......
    
    Flat profile of 0.08 secs (5 total ticks): main
      Interpreted + native   Method                        
     60.0%     0  +     3    java.io.FileInputStream.open
     20.0%     0  +     1    java.io.WinNTFileSystem.canonicalize0
     20.0%     0  +     1    java.io.WinNTFileSystem.getBooleanAttributes
    100.0%     0  +     5    Total interpreted
    
    0 error(s)
    Last edited by Norm; 02-20-2014 at 08:24 PM.
    If you don't understand my response, don't ignore it, ask a question.

  9. #49
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Why does Java process things very long?

    Look at it from our perspective. You are obviously in way over your head. If you're a student, you're not going to learn anything by having someone fix your program, even if we patiently explain it to you. You're completely out of your element, and you need to back up and start over from the beginning with something small. And if you're a professional, then we simply want you to fail. Many of us are professionals, and our lives are made harder every day by people who don't know what they're doing.
    SurfMan likes this.
    Get in the habit of using standard Java naming conventions!

  10. #50
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Why does Java process things very long?

    Error: Could not find or load main class C:\Documents

    Flat profile of 0.62 secs (50 total ticks): main

    Interpreted + native Method
    8.2% 0 + 4 java.io.WinNTFileSystem.canonicalize0
    4.1% 0 + 2 java.io.FileInputStream.open
    2.0% 0 + 1 java.lang.Class.forName0
    2.0% 1 + 0 sun.launcher.LauncherHelper$ResourceBundleHolder.< clini
    t>
    2.0% 1 + 0 java.util.zip.ZipFile$ZipFileInputStream.close
    2.0% 0 + 1 java.io.WinNTFileSystem.getBooleanAttributes
    20.4% 2 + 8 Total interpreted

    Thread-local ticks:
    2.0% 1 Blocked (of total)
    79.6% 39 Class loader

    Global summary of 0.62 seconds:
    100.0% 50 Received ticks
    2.0% 1 Compilation
    78.0% 39 Class loader


    Done, so? What does this mean? What next?

  11. #51
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,037
    Rep Power
    10

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    Done, so? What does this mean? What next?
    The error tells you that you didn't use the command correctly.

    Start here: https://www.google.com/search?q=java+xprof

    And if that's confusing, start here: The Java™ Tutorials
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #52
    Tawi is offline Senior Member
    Join Date
    Feb 2013
    Posts
    118
    Rep Power
    0

    Default Re: Why does Java process things very long?

    Please, just enable the link and download the files. I do not understand where to find it. Just explain it please. Don't ask me to find it myself.

  13. #53
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,037
    Rep Power
    10

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    Please, just enable the link and download the files. I do not understand where to find it. Just explain it please. Don't ask me to find it myself.
    We've given you many pieces of advice, linked you to several external resources, and asked you a bunch of questions that you've ignored. If you really don't know how to follow anything you've been told, you are biting off more than you can chew and should go back to the basics.

    I'm putting this thread out of its misery. Thread closed.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 1
    Last Post: 06-02-2013, 12:43 PM
  2. What are some cool begginer things to do with Java?
    By CiniCraft in forum New To Java
    Replies: 2
    Last Post: 09-11-2011, 11:13 PM
  3. Replies: 6
    Last Post: 03-23-2011, 07:53 PM
  4. A good Java installation package can make things much easier
    By freezea in forum Reviews / Advertising
    Replies: 2
    Last Post: 02-01-2009, 01:03 PM
  5. May someone explain what these things means in Java
    By quickfingers in forum New To Java
    Replies: 2
    Last Post: 01-26-2008, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •