I read an article about the new version of Dataflex, where it said that the time it took to do 5000 get/set operations had been reduced from 58 to 3 seconds.
I read it like: set and get an instance variable on an object 5000 times, but I presume that something more advanced is going on (otherwise, it's not that impressive).
But this got me wondering: how long does it take in Smalltalk?
So, I made a small class, with one instance variable: instancevar, and three methods: instancevar, instancevar: and runTest. The two former just gets/sets instancevar, and runTest does:
runTest | anInt | ^ Time millisecondsToRun: [1 to: 5000 do: [:z | self instancevar: z. anInt := self instancevar. Transcript show: anInt printString; cr]]
Now, I didn't have the "Transcript show" in it the first time I ran it.
Squeak printed: 1 Dolphin printed: 1
Question 1: Very nice. But am I missing something, where the compiler figures out that my instancevar is not used for anything else, and ignores it?
Next, I put the "Transcript show" in (I know, I know, that's not exactly testing the loop itself).
Squeak printed: 125585 Dolphin printed: 20711
Presumably Dolphin is faster because it is targeted at Windows.
Question 2: After "5000" was printed, both systems took a couple of seconds to come alive again (i.e. in Squeak, everything froze, in Dolphin, I got an hourglass). What were they doing? Was that the garbage collector at work, or?
Regards,
Kenneth Johnsen.
On Jun 27, 2004, at 11:49 AM, Kenneth Johnsen wrote:
I read an article about the new version of Dataflex, where it said that the time it took to do 5000 get/set operations had been reduced from 58 to 3 seconds.
I read it like: set and get an instance variable on an object 5000 times, but I presume that something more advanced is going on (otherwise, it's not that impressive).
But this got me wondering: how long does it take in Smalltalk?
So, I made a small class, with one instance variable: instancevar, and three methods: instancevar, instancevar: and runTest. The two former just gets/sets instancevar, and runTest does:
runTest | anInt | ^ Time millisecondsToRun: [1 to: 5000 do: [:z | self instancevar: z. anInt := self instancevar. Transcript show: anInt printString; cr]]
Now, I didn't have the "Transcript show" in it the first time I ran it.
Squeak printed: 1 Dolphin printed: 1
Question 1: Very nice. But am I missing something, where the compiler figures out that my instancevar is not used for anything else, and ignores it?
Nah, it's just that Smalltalk can do 5000 get/sets in less than a millisecond. On your machine, anyway. Mine takes 3 milliseconds for this test. Try 50,000 iterations.
Colin
Colin Putney wrote:
On Jun 27, 2004, at 11:49 AM, Kenneth Johnsen wrote:
I read an article about the new version of Dataflex, where it said that the time it took to do 5000 get/set operations had been reduced from 58 to 3 seconds.
I read it like: set and get an instance variable on an object 5000 times, but I presume that something more advanced is going on (otherwise, it's not that impressive).
But this got me wondering: how long does it take in Smalltalk?
So, I made a small class, with one instance variable: instancevar, and three methods: instancevar, instancevar: and runTest. The two former just gets/sets instancevar, and runTest does:
runTest | anInt | ^ Time millisecondsToRun: [1 to: 5000 do: [:z | self instancevar: z. anInt := self instancevar. Transcript show: anInt printString; cr]]
Now, I didn't have the "Transcript show" in it the first time I ran it.
Squeak printed: 1 Dolphin printed: 1
Question 1: Very nice. But am I missing something, where the compiler figures out that my instancevar is not used for anything else, and ignores it?
Nah, it's just that Smalltalk can do 5000 get/sets in less than a millisecond. On your machine, anyway. Mine takes 3 milliseconds for this test. Try 50,000 iterations.
Colin
50000 takes 14 ms in Squeak. So something is going on anyways. Btw. VisualWorks does 50000 in 1 ms, and 500000 in 9 ms :-)
Regards, Kenneth.
Hi!
Kenneth Johnsen kennethjohnsen@mail.dk wrote: [SNIP]
Next, I put the "Transcript show" in (I know, I know, that's not exactly testing the loop itself).
Squeak printed: 125585 Dolphin printed: 20711
Presumably Dolphin is faster because it is targeted at Windows.
Nah, the issue here is surely Transcript. Though Dolphin and Squeak is more or less on par with each other for many things. Both are interpreters without JITs. Dolphin may do some things faster since it calls win32 to do them, and Squeak may be faster at other things.
Question 2: After "5000" was printed, both systems took a couple of seconds to come alive again (i.e. in Squeak, everything froze, in Dolphin, I got an hourglass). What were they doing? Was that the garbage collector at work, or?
Might be, Transcript show: etc is not fun in a benchmark. :) It probably messes around with Strings creating garbage and might also be scrolling pixels in the window etc. etc.
Regards,
Kenneth Johnsen.
regards, Göran
squeak-dev@lists.squeakfoundation.org