Andy said:
In this case, I can't help but wonder why you chose to implement the system
in java.
I'm not the OP, but the fact that Java consistently outperforms most
other languages except for Fortran in floating-point calculation on many
common hardware platforms could have something to do with it... or it
might just have to do with ease of interacting with other code that's
written in Java and expected to run in-process. Do we need to have this
discussion every time another troll sees another opportunity to beat the
dead horse?
If there are just a couple of algorithms that need to be finely
tuned maybe you should use JNI and implement those in C.
Careful here. Aside from the obvious factors (that C code may well end
up being slower to begin with), the cost of crossing the JNI boundary is
very large when compared to performance differences between Java and C.
You're likely to see a serious drop in performance from the effort to do
the type coercions and such needed to cross between C++ and Java. If
the C code does benchmark substantially faster, it's a good idea to
design a higher-level API in the native language, in order to minimize
the number of switchover points.
Even if you can find a way to change the machine code that gets executed for
a particular piece of java code, this won't be portable across hardware or
JVMs
This is a very good point. When you ask this question, the answer has
to be at least specific to JVM vendors and platforms; and what's more,
it's likely to be specific to the specific deployment hardware and
environment. For example, your average C compiler will generally target
only the common operations between an entire family of processors unless
you specifically choose otherwise, but a JIT compiler will generally
make use of whatever specific performance tricks are available for
whatever processor you've really got. Decisions on inlining or not may
be similarly based on how much memory is available to the process, and
its danger of swapping, and what the JIT knows about your processor's
branch optimization abilities.
Even further, you need to specify at what *point* in the execution you
want to know this stuff. Code may be changed around dynamically at
runtime at arbitrary points. For example, a virtual method call may be
inlined at one point because the compiler knows that you've only
instantiated one kind of object so there's only one possible target
method implementation; but that optimization can be undone when you
later load a new class that overrides the method and create an object of
that.
In essence, the answer to the OP's question is likely to be far more
complicated than the OP expects. Things just aren't that simple any
longer.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation