Naive number questions

stéphane ducasse ducasse at iam.unibe.ch
Tue Nov 2 20:41:48 UTC 2004


hi guys

one guy in the french mailing llist posted that:

In Java

  long x = 0;
    long timeStart = 0;
 
    timeStart = System.currentTimeMillis();
 
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 100000000; j++) {
            x = x + 1;
        }
    }
 
    timeStart = System.currentTimeMillis() - timeStart;
    System.out.println(new Long(timeStart).toString());
    System.out.println(new Long(x).toString());
 
==> 487 secondes.

in Squeak: but it took a lot more (in fact I stopped it).
Is there any reason why?

Time millisecondsToRun: [
| x |
x := 0 .
1000 timesRepeat: [
	100000000 timesRepeat: [ x := x + 1 ] ] ].

Stef





More information about the Squeak-dev mailing list