943,587 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3258
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 26th, 2007
0

Optimization

Expand Post »
How can a Java program be optimized? I have no experience in this thematic so I could use some key words so I acn go deeper into it!
Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rinko is offline Offline
12 posts
since Apr 2007
Apr 26th, 2007
0

Re: Optimization

There is no specific answer to this question, so I'll give you a general one..
First find out what need to be optimized? For this you can use tools like Rational/IBM Quantify (license issues) or Mocking Framework (in this you'll need to write some code of your own).
Once you know what has to be optimized, you can ask a specific question, then we can write more specific answers.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Apr 27th, 2007
0

Re: Optimization

a mocking framework won't tell you what needs optimising.
A profiler may, but not a mock object (if anything it will likely hide the reason for any performance problems).

Most often when people "optimise" code they are just guessing where the problems are, grasping at straws and doing things they once heard someone say would make things faster (and usually they don't of course).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Apr 28th, 2007
0

Re: Optimization

Click to Expand / Collapse  Quote originally posted by jwenting ...
Most often when people "optimise" code they are just guessing where the problems are, grasping at straws and doing things they once heard someone say would make things faster (and usually they don't of course).
Not always true -- well maybe true for beginners who think their code needs optimization for no good reason other than the thing that 'optimization' is a cool word. Take for example String and StringBuffer class in scenarios where appending is frequent. Same thing for Vector and ArrayList.

One should know where to look when it comes for optimization.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Apr 29th, 2007
0

Re: Optimization

I've seen highly experienced people go wrong on "optimisation" when they didn't know the underlying machine instructions being generated (and few people know those).
That was C of course, but in Java deep knowledge is often also needed to get beyond the blatantly obvious stuff.

Things like loop and callstack optimisation aren't all that well known to many people.
SQL optimisation is an especially black art...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
May 2nd, 2007
0

Re: Optimization

Click to Expand / Collapse  Quote originally posted by jwenting ...
a mocking framework won't tell you what needs optimising.
A profiler may, but not a mock object (if anything it will likely hide the reason for any performance problems).
It's just a use of mocking framework that we've found.. you can put out a trace at entry and exit every function. The trace is supposed to have particular information (time for one).. run your program with it and put down the traces in excel or run an awk/shell/perl script and you'll have your performance report.. (that's the reason I mentioned you'll have to write some code of your own)..
The reason why I suggested this in the first place is I donno how accessible Rational Quantify (or other licensed tools) are to this guy.. if they aren't one can always work around it..
Finally, no tool tells you what to optimize (not even Quantify).. they just give you a report and then just go figure..
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
May 2nd, 2007
0

Re: Optimization

nice, but how are you going to trace the time needed for the functionality you replaced by those mocks (which usually is the expensive stuff like database and network operations)?
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
May 5th, 2007
0

Re: Optimization

Click to Expand / Collapse  Quote originally posted by jwenting ...
nice, but how are you going to trace the time needed for the functionality you replaced by those mocks (which usually is the expensive stuff like database and network operations)?
You don't mock any objects ! Just define pointcuts for entry/exit of all classes/functions you wanna measure and add before()/after() to trace.
Will post teh code if possible.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
May 8th, 2007
0

Re: Optimization

Click to Expand / Collapse  Quote originally posted by thekashyap ...
You don't mock any objects ! Just define pointcuts for entry/exit of all classes/functions you wanna measure and add before()/after() to trace.
Will post teh code if possible.
I just put Narue's sorting algorithms thru a performance test.
Here is what the output looks like when I put it in an excel sheet.
Have posted the code used in code snippets. My first Java 5.0 code.
Attached Thumbnails
Click image for larger version

Name:	Output.jpg
Views:	12
Size:	61.1 KB
ID:	3380  
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
May 8th, 2007
0

Re: Optimization

Hi Kashyap,

Did you tested the functionality of AspectJ with Web Services ...? I used WSIF demo also but i'm facing various issues .If you have any documents or links pointing to this then please post it here.

Thanks
Last edited by lucky1981_iway; May 8th, 2007 at 4:44 am.
Reputation Points: 10
Solved Threads: 3
Light Poster
lucky1981_iway is offline Offline
46 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Assignment Help ASAP!
Next Thread in Java Forum Timeline: AspectJ problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC