How to make java not get stuck while performing String operation
Hi,
I am working on a compression class. So far, I can get the program to compress 100 bytes to 44 bytes. However, when I increase the block size, or I mean the amount of data in the buffer, it takes java alot longer to finish the program. Even though the program is running on a thread. Java gets stuck, and I have to wait long before it finish the compression task. Not to mention the same thing, hanging over when performing the decompression task.
Let me put it into perspective: (the numbers are from actual code running in a thread):
Let say compressing 100 bytes takes 609 milliseconds. Not bad, barely a second. However, 200 bytes, takes 1.702 seconds + milliseconds. Thats 1.093 seconds + milliseconds more than the previous 100 byte task. Now with 300 bytes takes 3.415 seconds + milliseconds. Thats again, 1.713 seconds, or 62 milliseconds more than previous 200 bytes task. And Lastly, 400 bytes takes 6.757 seconds + milliseconds, thats 3.342 seconds + milliseconds more, or 1.629 seconds + milliseconds more than the previous 300 byte task.
What I am trying to say, is that the task is taking too long to finish. Is there a way to go around this. I know that threads make things concurrent, but even like this is taking too long.
Help anyone.
I mean the reason the program is taking so long is because it is performing string operations.
Is there a way to make java perform faster under string operation work load?
Re: How to make java not get stuck while performing String operation
If you want help, I suggest you provide an SSCCE showing the benchmark you want to improve.
Re: How to make java not get stuck while performing String operation
Also read the API focumentation for the StringBuilder class (or if you prefer: the StringBuffer class).
kind regards,
Jos