Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / July 2005

Tip: Looking for answers? Try searching our database.

Benchmarks for operations in primitive types

Thread view: 
Dario Alpern - 23 Jul 2005 18:32 GMT
Hello folks,

I was comparing the Sun Java Virtual Machine against the old Microsoft
one, and I found that it is slower for int and double multiplication
than the MS JVM.

The values I found are the following, where the computer has a Duron
1300 MHz processor and 256 MB of RAM:

         SUN          SUN           MICROSOFT
       1.4.2_04     1.5.0_04        5.0.0.3810
int      20590        21140            13290
double   18950        21090            10710
long     36080        35540            40700

It appears that there is much room for improvement in the Sun JVM
given that the MS JVM is very old.

The programs are shown below:
================================================================
public class test1
{
 public static void main(String args[])
 {
   int i,j;
   double [] pepe = new double [200];
   long k = System.currentTimeMillis();
   for (j=0; j<10000000; j++)
   {
     for (i=0; i<200; i++)
     {
       pepe[i] = 5647239564d;
     }
     for (i=0; i<200; i++)
     {
       pepe[i] = pepe[i] * 657805890d;
     }
   }
   System.out.println(System.currentTimeMillis() - k);
 }
}

================================================================
public class test2
{
 public static void main(String args[])
 {
   int i,j;
   long [] pepe = new long [200];
   long k = System.currentTimeMillis();
   for (j=0; j<10000000; j++)
   {
     for (i=0; i<200; i++)
     {
       pepe[i] = 5647239564l;
     }
     for (i=0; i<200; i++)
     {
       pepe[i] = pepe[i] * 657805890l;
     }
   }
   System.out.println(System.currentTimeMillis() - k);
 }
}
===========================================================
public class test3
{
 public static void main(String args[])
 {
   int i,j;
   int [] pepe = new int [200];
   long k = System.currentTimeMillis();
   for (j=0; j<10000000; j++)
   {
     for (i=0; i<200; i++)
     {
       pepe[i] = 56472395;
     }
     for (i=0; i<200; i++)
     {
       pepe[i] = pepe[i] * 65780589;
     }
   }
   System.out.println(System.currentTimeMillis() - k);
 }
}

Best regards,

Dario Alpern
Buenos Aires - Argentina
Denis Gurchenkov - 26 Jul 2005 07:22 GMT
Few notes on your results:

1. What you did is "microbenchmarking" - that is, you wrote tiny
programs that measures one specific language construction. This is not
simlar to typical Java code, which is much bigger and contains
spaghetti of branches, heap accesses, virtual calls, instance checks
etc.

I think that Sun VM guys just do not spend too much time optimizing
their VM exactly for such microbenchmarks, they use bigger and
different tests, such as SpecJVM, SpecJBB etc instead. This may be the
reason.

2. If you want to compare MS JVM to modern Java, you may also compare
it with HotSpot Server VM (java -server) and with other JVMs (BEA
JRockit, Excelsior JET).

Denis

--------------------
www.excelsior-usa.com/jet.html
JVM with Ahead-of-Time Compiler
Dario Alpern - 26 Jul 2005 15:02 GMT
> Few notes on your results:
>
[quoted text clipped - 12 lines]
> it with HotSpot Server VM (java -server) and with other JVMs (BEA
> JRockit, Excelsior JET).

Denis,

My factorization applet ( http://www.alpertron.com.ar/ECM.HTM ) uses a
lot of array access and primitive types and very few objects. So this
is not a microbenchmark, but the measurement of a real bottleneck in
my application where I found that the Sun Java Plugin makes my applet
to run almost half as fast as the old Microsoft JVM.

Best regards,

Dario Alpern
Denis Gurchenkov - 27 Jul 2005 06:04 GMT
> Denis,
>
[quoted text clipped - 7 lines]
>
> Dario Alpern

Dario, I did not intend to harm you, neither I want to say that your
program is not Java :-)

You are quite right - on your benchmark, the Sun's JVM is very slow. I
just have run the "ecm.java", and it runs 4 times faster on MS JVM
compared to Sun's. However, fast speed of MS JVM is no magic: IBM Java
is even faster (on this bench), and other JVMs reside in the middle of
the range.

I just wanted to suggest a possible reason, why Sun's JVM is so slow.
This is not a secret that most money nowadays are in enterprise Java,
in the world of very big server-side applications, which run for days.
They are indeed different from your code. So, it may be that Sun
invests its performance-improvement efforts into speedup of enterprise
Java applications, but not into speedup of numeric, integer-based apps
as yours.

Perhaps, with introduction of the Fortress language Sun will invest
more into perofrmance of numeric applicaitons.

Denis.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.