Benchmarks for operations in primitive types - Java

This is a discussion on Benchmarks for operations in primitive types - Java ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

Benchmarks for operations in primitive types

  1. Default Benchmarks for operations in primitive types

    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

  2. Default Re: Benchmarks for operations in primitive types

    alpertron@hotmail.com (Dario Alpern) wrote in message news:<1abc6a46.0507230932.7582a703@posting.google.com>...

    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

  3. Default Re: Benchmarks for operations in primitive types

    htayod@ngs.ru (Denis Gurchenkov) wrote in message news:<1bddc9de.0507252222.29358a12@posting.google.com>...
    > alpertron@hotmail.com (Dario Alpern) wrote in message news:<1abc6a46.0507230932.7582a703@posting.google.com>...
    >
    > 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,

    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

  4. Default Re: Benchmarks for operations in primitive types

    alpertron@hotmail.com (Dario Alpern) wrote in message news:<1abc6a46.0507260602.6597a5aa@posting.google.com>...
    >
    > 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


    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.

+ Reply to Thread

Similar Threads

  1. using constructors for primitive types?!
    By Application Development in forum c++
    Replies: 8
    Last Post: 06-18-2007, 06:18 AM
  2. STL interface in C for primitive types
    By Application Development in forum C
    Replies: 9
    Last Post: 01-08-2005, 12:12 AM
  3. Re: Size of primitive types?
    By Application Development in forum Java
    Replies: 1
    Last Post: 05-29-2004, 02:15 PM
  4. null return values for property getters for primitive types?
    By Application Development in forum Java
    Replies: 4
    Last Post: 05-17-2004, 03:37 AM