Newsgroups: comp.lang.java.programmer
From: megagu...@yahoo.com (Jesper Nordenberg)
Date: 2 Jun 2005 11:56:24 -0700
Local: Thurs 2 Jun 2005 19:56
Subject: Re: Optimise my ray tracer
Jon Harrop <use...@jdh30.plus.com> wrote in message <news:429e5795$0$7560$ed2619ec@ptn-nntp-reader03.plus.net>... Without studying your code thoroughly I would suggest you reuse Vector > I've written a mini ray tracer for the computer language shootout. The > original version was written in OCaml which I ported to C++: > http://www.ffconsultancy.com/free/ray_tracer/comparison.html > I have since ported the program to several other languages, including Java. > These are my main questions: > 1. What major optimisations are missing from my program (e.g. in C++, I pass objects (and other objects) in your operations instead of creating a new ones. Even with the latest Hotspot JVM, creating new objects are still way slower than reusing them. For example: Vec add(Vec a, Vec b) becomes: Vec add(Vec a, Vec b) { } Only create new objects when you need to. This optimization will require some changes in the code structure and makes it slightly harder to read. Another optimization is to replace the LinkedList with an ArrayList Also remember to use the -server option when running the program, it One other thing to try is to use float instead of double (if the Remember that the Hotspot JVM requires a quite long warmup before With these optimizations I think the performance will be similar to > 3. How do you do infix operators in Java? Do you mean operator overloading? Not supported in Java. > 4. Am I supposed to have a static main function which instantiates a class Yes, that works. > and invokes a member function of it in order to start the program? /Jesper Nordenberg 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.
| ||||||||||||||