On Tue, 9 Nov 2010, Guido Stepken wrote:

E.g.: Three different solutions for a Euler problem:

(1 to: 999) inject: 0 into: [:sum :i | (i \\ 3 = 0) | (i \\ 5 = 0)
                ifTrue: [sum + i]
                ifFalse: [sum]]


(1 to: 999) detectSum: [:i | (i \\ 3 = 0) | (i \\ 5 = 0) ifTrue: [i] ifFalse: [0]]

(1 to: 999) detectSum: [:i | i * (#(0 0 1 0 1 1 0 0 1 1 0 1 0 0 1) atWrap: i)]

How do i measure the exact memory footprint of each solution?

I think you could measure it with the simulator. But these snippets are so simple that they only use at most few kilobytes.


Pharo claims having reduced memory footprint at many places. Can that be proofed, e.g. with one comparable demo app, once run in old squeak, once in Pharo 1.1/1.2?

You misunderstood Pharo's claims. It doesn't mean that running code in Pharo will use less memory than in Squeak. It means that the image is smaller, because it contains less stuff. So, there's nothing to be proven. Btw it's funny that you refer to Squeak as "old".


And no, MessageTally spyOn: does not do right!

MessageTally is for measuring runtime, not space. But I guess the GC statistics are reliable, so the allocated memory and time spent in GC is correct even on CogVM. But your code runs too fast for MessageTally.


Levente


Tnx in advance, Guido Stepken




Reply via email to