Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Optimizing Java

Optimizing Java
Thread Tools
kstor
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Apr 15, 2004, 04:02 PM
 
Hi

Has anyone tried using Apple's optimization tools on Java programs?
I was trying to use Shark, but it couldn't find my source code. The documentation is very light, and all their examples seem to use c/c++/objc code...

Otherwise, what tools can you use to analyze and optimize Java code?

KStor
     
Kristoff
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 15, 2004, 05:28 PM
 
Your brain.

Seriously. I have seen people write some **** code, complain how slow "java" is, run it through a profiler/optimizer, and have it run just as slow. When looking at their code, it's complete crap.

I am not saying that you write crap. But, make sure you read some books on best practices. You'd be surprised how much faster your code is when you think about what you're doing.
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Thinine
Mac Elite
Join Date: Jul 2002
Status: Offline
Reply With Quote
Apr 15, 2004, 07:15 PM
 
If you launch Shark from within Xcode, it'll automatically know where your code is.
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Apr 15, 2004, 08:20 PM
 
Originally posted by kstor:
Hi

Has anyone tried using Apple's optimization tools on Java programs?
I was trying to use Shark, but it couldn't find my source code. The documentation is very light, and all their examples seem to use c/c++/objc code...

Otherwise, what tools can you use to analyze and optimize Java code?

KStor
I don't know about tools, but there are lots of good "rules of thumb" to optimize java. Stuff like using primitives instead of classes where possible, using unsynchronized classes (ArrayList vs. Vector) where thread safety is not an issue, adjusting memory size and new size to reduce garbage collection, etc.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
itai195
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status: Offline
Reply With Quote
Apr 15, 2004, 08:29 PM
 
If you want a commercial tool, there is Borland Optimizeit.
     
kstor  (op)
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Apr 15, 2004, 11:11 PM
 
I'm not really doing this for performance, it's more out of curiosity. I want to see how helpful Apple's tools are...

Thinine:
I launched Shark from within XCode, but it still doesn't find the source. I just get a lot of NO_SYMBOL and UNREADABLE_PAGE entries. Any clues?

KStor
     
absmiths
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Apr 23, 2004, 02:14 PM
 
Originally posted by itai195:
If you want a commercial tool, there is Borland Optimizeit.
Or JProfiler, my favorite. But the best use of these tools is simply to concentrate your efforts where it matters most, not fix your problems for you. Tools that modify my source make my VERY nervous.
     
thefamousmred
Junior Member
Join Date: Mar 2002
Status: Offline
Reply With Quote
Apr 23, 2004, 03:21 PM
 
Originally posted by absmiths:
Or JProfiler, my favorite. But the best use of these tools is simply to concentrate your efforts where it matters most, not fix your problems for you. Tools that modify my source make my VERY nervous.
What, like the compiler?
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Apr 23, 2004, 04:53 PM
 
Originally posted by thefamousmred:
What, like the compiler?
Uh, I see your smiley, but this is not technically correct. A compiler doesn't modify source, it generates object code from source code. (Well, some compilers generate intermediate assembler code, and then that is run through an assembler which generates object code) That's why it is called source code - it is the source, not the generated output. Yes, no doubt there can be bugs in compilers in what object code they generate, and there can especially be issues with attempts at optimizing generated object code, but compilers do not modify source code.
     
thefamousmred
Junior Member
Join Date: Mar 2002
Status: Offline
Reply With Quote
Apr 23, 2004, 09:11 PM
 
Originally posted by JNI:
Uh, I see your smiley, but this is not technically correct. A compiler doesn't modify source, it generates object code from source code. (Well, some compilers generate intermediate assembler code, and then that is run through an assembler which generates object code) That's why it is called source code - it is the source, not the generated output. Yes, no doubt there can be bugs in compilers in what object code they generate, and there can especially be issues with attempts at optimizing generated object code, but compilers do not modify source code.
While we're being pedantic, compilers don't have to produce object code. Some compilers produce more source code - many LISP compilers output C, for example. javac doesn't produce object code. Instead it produces bytecodes which are interpreted at runtime by a bytecode intepreter, which generates the machine code on the fly.
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Apr 24, 2004, 06:26 PM
 
It's all semantics. Whether or not that is trivial is a matter of opinion.

My point was that compilers don't 'modify' source - they 'generate' stuff.

[edit: just clarification of my point, removed debate on what is an 'object' file...]
( Last edited by JNI; Apr 25, 2004 at 02:24 PM. )
     
absmiths
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Apr 27, 2004, 05:28 PM
 
Originally posted by thefamousmred:
What, like the compiler?
Yes, that is silly. Whatever the compiler does, it doesn't modify my source. There is a big difference between using an optimization product in use by +/- 10,000 developers, or using the javac compiler that nearly 100% of all Java developers use and has bascially been around for over a decade.

Anyway, if you can't trust your compiler then you are out of luck.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:02 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,