Google Groups Home
Help | Sign in
Message from discussion Optimise my ray tracer
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Scott Ellsworth  
View profile
 More options 2 Jun 2005, 21:43
Newsgroups: comp.lang.java.programmer
From: Scott Ellsworth <sc...@alodar.com>
Date: Thu, 02 Jun 2005 13:43:45 -0700
Local: Thurs 2 Jun 2005 21:43
Subject: Re: Optimise my ray tracer
In article <429e5795$0$7560$ed261...@ptn-nntp-reader03.plus.net>,
 Jon Harrop <use...@jdh30.plus.com> wrote:

> I have since ported the program to several other languages, including Java.
> Currently, the Mlton-compiled SML, OCaml, C++ and Fortran are the fastest,
> and Java trails a long way behind. I am concerned that this is because I am
> a much better OCaml/C++ than Java programmer so I'm asking for advice here.

I strongly, strongly suggest finding a profiler.  Such a beast can tell
you where your CPU cycles are going, which will help you optimize them.  
If you are on Windows, the NetBeans folks have the JFluid profiler built
in, on some builds.  On the Mac, the Shark profiler is included with the
developer tools.  I have had great success with JProfiler, and the
JetBrains folks seem to really like YourKit.  (The first two are free,
the second are for pay.)

As always, try to take a high level look at the profiler's results.  For
example, if it tells you that one arithmetic operation is the big cost,
try to decide whether you can not do the computation, or change the
algorithm to do that task fewer times before trying to get a ++ or -- to
execute faster.

In Java, the above vague advice usually translates to looking at when
and how you are creating objects, and making sure you do not have
excessive synchronization overhead.  Also, a few Sun classes are quite
lame, and worth rewriting.  (If, and only if, they are taking
appreciable time...)

Then, once you know your algorithm is appropriate, tune the lines of
code that matter.

Scott


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google