Hi,
I was curious how much speedup Cog gives when the code has only a few message sends, so I ran the following "benchmark":
| s1 s2 | Smalltalk garbageCollect. s1 := String streamContents: [ :stream | 1000 timesRepeat: [ 'aab' do: [ :e | stream nextPut: e; cr ] ] ]. s2 := String streamContents: [ :stream | 1000 timesRepeat: [ 'abb' do: [ :e | stream nextPut: e; cr ] ] ]. [ TextDiffBuilder from: s1 to: s2 ] timeToRun.
The above pattern makes TextDiffBuilder >> #lcsFor:and: run for a while. My results are a bit surprising: CogVM: 2914 SqueakVM: 1900
MessageTally shows that (I wonder if it's accurate with Cog at all) CogVM's garbage collector is a bit better, but it runs the code slower than SqueakVM:
CogVM: **Leaves** 60.6% {1886ms} TextDiffBuilder>>lcsFor:and: 36.2% {1127ms} DiffElement>>= 1.8% {56ms} ByteString(String)>>=
**GCs** full 1 totalling 153ms (5.0% uptime), avg 153.0ms incr 21 totalling 76ms (2.0% uptime), avg 4.0ms tenures 13 (avg 1 GCs/tenure) root table 0 overflows
SqueakVM: **Leaves** 46.8% {888ms} TextDiffBuilder>>lcsFor:and: 35.3% {670ms} DiffElement>>= 9.8% {186ms} ByteString(String)>>compare:with:collated: 6.9% {131ms} ByteString(String)>>=
**GCs** full 3 totalling 254ms (13.0% uptime), avg 85.0ms incr 301 totalling 110ms (6.0% uptime), avg 0.0ms tenures 272 (avg 1 GCs/tenure) root table 0 overflows
Is Cog slower because #to:do: loops are not optimized, or is there some other reason for the slowdown?
Levente