[Kde-java] Re: [Kde-bindings] Using a custom RealProxy to implement a C# SMOKE adaptor

Marco Ladermann Marco.Ladermann at gmx.de
Fri Aug 22 21:03:58 CEST 2003


On Friday 22 August 2003 14:49, Richard Dale wrote:
> On Friday 22 August 2003 12:08, Marco Ladermann wrote:
> > Am Freitag, 22. August 2003 12:32 schrieb Richard Dale:
> > > I've done a quick comparison of the overhead of a Proxy invocation vs.
> > > JNI in Java, and the JNI call is about 10x faster. On an 800 MHz iBook,
> > > this loop with 10 million method calls took 3.5s in JNI against 35s via
> > > proxy calls:
> > >
> > > 		QFont myFont = new QFont();
> > >
> > > 		for (int count = 0; count < 5000000; count++) {
> > > 			myFont.setPointSize(18);
> > > 			QFont.removeSubstitution("Times Roman");
> > > 		}
> > >
> > > So about 3 million method calls/s vs 0.3 million/s.
> >
> > Did you take into account that the reflection API was considerably
> > improved in Java 1.4.x (see:
> > http://java.sun.com/j2se/1.4.1/docs/guide/reflection/)? If your JVM
> > version is 1.3 you might get better results with a more uptodate JVM.
>
> I don't think Java 1.4.x is available for PowerPC Linux yet, so I can't
> upgrade. I've attached the test I ran, I'll cc this mail to the kdejava
> list, so other people can try it, and we can carry discussing there
> perhaps. I haven't compiled with gcj - that would be an interesting
> comparison.
>

My Java 1.4.2 complained about "main not public" in Doit.java, but that was 
easily fixed.

Here are the results:
$ java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

$ cat /proc/cpuinfo
rocessor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : Celeron (Mendocino)
stepping        : 5
cpu MHz         : 411.143
cache size      : 128 KB
...

$ cd jni
$ time java -Djava.library.path=. -cp .  Doit

real    0m3.754s
user    0m3.470s
sys     0m0.010s

$ cd ../proxy
$ time java -cp . Doit

real    0m6.056s
user    0m5.430s
sys     0m0.150s

$ gcj *.java -o doit --main=Doit
$ time ./doit

real    1m7.409s
user    1m0.240s
sys     0m0.400s

JNI is still faster but less than two times, which seems acceptable to me. But 
gcj ...

Marco
-- 



More information about the Kde-java mailing list