This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: my crude benchmark results


John Gabriele wrote:
>          for ( int i = 0; i < SIZE; ++i )
>          {
>              nums[i] = Math.random() * 3.14159 / 2.0;
>          }

I note that at least on the 3.4 branch and mainline,
Math.random() is a synchronised method, so the loop
above represents acquiring a lock on java.lang.Math
and releasing it 50,000 times!

If you want to eliminate this factor, you can perhaps
write out a pre-computed array and link that in. You'll
also have to do it for the C version, just to be fair.

Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]