Page 1 of 3 123 LastLast
Results 1 to 20 of 53
Like Tree5Likes

Thread: Why does Java process things very long?

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

    Default Why does Java process things very long?

    I create a Java program. I try to make it to process a long calculation but it process the calculations very long, the question is why?

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

    Default Re: Why does Java process things very long?

    There are many reasons a program runs for a long time. In fact, it is possible to write a program that never stops.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Why does Java process things very long?

    Hi Tawi,

    can you give details about your application? Maybe you can build a small example that shows the core problem that could be reviewed?

    There are a lot of reasons, why a calculation takes long:
    - Maybe it is simply the calculation. (e.g. calculating pi for 10000 digits could take quite long.)
    - Maybe something can be optimized (common things that might take long with managed applications is allocating / deallocating memory very often. Or the algorithm to get something might need optimisation.)

    WIth kind regards,

    Konrad

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

    Default Re: Why does Java process things very long?

    Please open this link: AdF.ly - shrink your URLs and get paid! (spammy link removed by moderator). I put the program in this link because the program is very long. I make a button and at the time I set the button text to "proses" and click it, it take Java very long to process it, why?
    Last edited by KevinWorkman; 02-17-2014 at 07:27 PM.

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

    Default Re: Why does Java process things very long?

    Sorry, I do not go to other sites. 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.
    Last edited by Norm; 02-16-2014 at 06:32 PM.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    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?

    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.
    Get in the habit of using standard Java naming conventions!

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

    Default Re: Why does Java process things very long?

    Not because I do not want to create that but because it is an integrated program. I am suspecting that this program uses plenty of calculations and because of that, it is processing the calculation very long so please look at it and tell me that I am correct or not. Please open the site and see it. I have limited time and I have no time to create those things, what is the mistake? One more, what is -Xprof option in Java?

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

    Default Re: Why does Java process things very long?

    what is -Xprof option in Java?
    java is the name of a program that starts the execution of a java class.
    The -Xprof option is for the java command's commandline when it is executed:
    java -Xprof TheClassNameHere

    I have no time to create those things
    Then I suggest that you hire a java programmer to find your problem. We're volunteers here.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    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?

    A large amount of code does not necessarily mean the program will be slow. You need to identify the algorithms the program is using and determine their time complexity. A small, cleanly-written program that runs in O(n!) could very easily be slower than a huge, badly-written program that runs in O(n). If the program is poorly written but the algorithm is optimal, you may not gain much from fixing it. And you need to know what you stand to gain before you undertake what may be a very expensive project.
    Get in the habit of using standard Java naming conventions!

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

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    Please open this link: AdF.ly - shrink your URLs and get paid!
    Let me get this straight: you want us to pay to help you? You're sending us through a spammy service just to get to your code? That's pretty rude- shouldn't you make it as easy as possible for people to help you?

    If you want help, you'll have to provide an SSCCE that demonstrates the problem. Isolate the code that's taking a long time and post that here. That should be step one when you have a problem in your code.

    I'm going to remove your spammy link.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  11. #11
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    I have limited time and I have no time to create those things
    So you have a problem and expect us to check out your web site because you don't have time to follow the forum rules?? If you really want help you need to take the time to post an Short, Self Contained, Correct Example

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

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

    Default Re: Why does Java process things very long?

    Quote Originally Posted by jim829 View Post
    So you have a problem and expect us to check out your web site because you don't have time to follow the forum rules?? If you really want help you need to take the time to post an Short, Self Contained, Correct Example

    Regards,
    Jim
    No guys, you are wrong. I need money. You do not need to pay to visit the site, do you? That is not my site. I put it at Ziddu to make you able to get it easily. Please get the file from it and try to tell me the problem that is happening. I do not mean to ask you to pay. I told you that it is an integrated program. How to make it simple anyway? I do not even know where to delete? It is not a spam. I need money so I only need you to help me meanwhile you are helping me to solve my problem.
    Last edited by Tawi; 02-17-2014 at 09:55 PM.

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

    Default Re: Why does Java process things very long?

    Quote Originally Posted by Tawi View Post
    I need money.
    This is a technical forum meant for specific questions about Java. There are other forums more suited to advertisements, and I'd be happy to move this thread there for you.

    If you have a specific technical question, follow the specific technical instructions and requests you've been given, and we'll be happy to help.

    It's up to you how to proceed. You can post the code in the form of an SSCCE, or I can move this thread to the advertisements forum.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: Why does Java process things very long?

    I do not know how to break it. I do not mean to advertise. Believe me.

  15. #15
    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?

    The point is that you need to pay if you want someone to look at a large, complex program and tell you what's wrong with it. If you want free help, write a SSCCE.
    Norm likes this.
    Get in the habit of using standard Java naming conventions!

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

    Default Re: Why does Java process things very long?

    Quote Originally Posted by kjkrum View Post
    The point is that you need to pay if you want someone to look at a large, complex program and tell you what's wrong with it. If you want free help, write a SSCCE.
    The problem is the program is related one another, how to break it? Please see it and tell me what is wrong, will you? I tried to break it but I was only able to make it 10 lines shorter, so please help me.
    Last edited by Tawi; 02-17-2014 at 10:54 PM.

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

    Default Re: Why does Java process things very long?

    The SSCCE link contains instructions on breaking a problem down into smaller pieces. Here's another explanation of the same process: How to create a Minimal, Complete, Tested and Readable example - Help Center - Stack Overflow
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: Why does Java process things very long?

    I don't think an SSCCE is going to help here. I mean this is about performance problems and more specifically: not knowing where that problem is. So how would you then extract that which you can't find into a small example?

    There is but one real answer here: 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).
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: Why does Java process things very long?

    Quote Originally Posted by gimbal2 View Post
    I don't think an SSCCE is going to help here. I mean this is about performance problems and more specifically: not knowing where that problem is. So how would you then extract that which you can't find into a small example?

    There is but one real answer here: 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).
    I would argue that the 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.

    But I would say the chances of *any* of that happening are pretty slim, so I'm not holding my breath.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: Why does Java process things very long?

    Using a profiler is still less effort. But I'll meet you halfway, because it is also an approach that requires a more experienced mind, your suggestion of adding timing code is more fitting for people who are still in the code hacking phase of their upbringing.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Page 1 of 3 123 LastLast

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
  •