More interesting data points:

On a 64-bit machine running linux there's no difference between the
client and server times. I don't know whether this is because the
64-bit client and server VM optimisations aren't as different as they
are in 32-bit mode or whether there's some advantage to 64-bit here
(if there is, gcc isn't taking advantage of it, see below).

The obvious C translation of

#include <stdio.h>

int main(){
    long bits = 0L;
    int  n = 2000000001;
    while (n > 0) {
      bits ^= (1 << 5);
      n--;
    }
    printf("%d", bits);
}

Seems to take longer than the client time, regardless of whether it's
in 64 or 32 bit mode.

On Dec 1, 2007 3:18 AM, David Pollak <[EMAIL PROTECTED]> wrote:
> Yeah, the Scala code was a port of Java code that does similar things.  With
> the Scala command line and some other Scala tools, it's much faster to make
> a change and test the change with Scala than with Java.
>
>
>
>  On 11/30/07, David MacIver <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> > For what it's worth, the obvious Java translation does the same thing:
> >
> > class Foo{
> >   public static void main(String[] args){
> >     long bits = 0L;
> >     long start = System.currentTimeMillis();
> >     int  n = 2000000001;
> >     while (n > 0) {
> >       bits ^= (1 << 5);
> >       n--;
> >     }
> >     System.out.println(bits);
> >     long end = System.currentTimeMillis();
> >     System.out.println(end-start);
> >
> >   }
> > }
> >
> > So it isn't a quirk of the bytecode scala produces
> >
> >
> > On Nov 30, 2007 11:18 PM, Erik Engbrecht <[EMAIL PROTECTED]> wrote:
> > > David,
> > > For me 1.5 and 1.6 perform about the same...1.6 is a little faster.
> > > However, -server yields the surprisingly fast results that you are
> seeing
> > > under 1.6 and -client yields the slow results that you are seeing under
> 1.5.
> > >
> > > It still doesn't explain why it's so fast...but it's another data point.
> > > I'm using an ancient computer with Linux.
> > >
> > > -Erik
> > >
> > >
> > > On Nov 30, 2007 5:49 PM, David Pollak < [EMAIL PROTECTED]>
> > > wrote:
> > > > I've got the following Scala code:
> > > > object Foo {
> > > >   def main(argv: Array[String]) {
> > > >     var bits = 0L
> > > >     val start = System.currentTimeMillis()
> > > >     var n = 2000000001
> > > >     // var n = 2000000001L // makes things very slow
> > > >     while (n > 0) {
> > > >       bits = bits ^ (1 << 5)
> > > >       n = n - 1
> > > >     }
> > > >     System.out.println(bits)
> > > >     val end = System.currentTimeMillis()
> > > >     System.out.println (end-start)
> > > >   }
> > > > }
> > > >
> > > > I'm enclosing the source and the bytecode.
> > > >
> > > > There are 2B iterations.
> > > >
> > > > On my Core 2 Quad running JDK 1.6 (32 bit), the code takes 2 ms to
> run.
> > > >
> > > > On my Mac Book Pro (Core Duo, JDK 1.5) it takes 6,600 ms.
> > > >
> > > > The run time on the Mac seems more "reasonable".  What's going on?
> > > >
> > > >
> > > >
> > > > --
> > > > lift, the secure, simple, powerful web framework http://liftweb.net
> > > > Collaborative Task Management http://much4.us
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > http://erikengbrecht.blogspot.com/
> > >
> > >
> > >  >
> > >
> >
> > http://liftweb.net
> > Collaborative Task Management http://much4.us
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to