[Pharo-dev] Small text composition bench

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sat Oct 12 06:06:04 EDT 2013


Ah, thanks Denis, my first look was too superficial.
I must also load a more recent version (I started with Igor's 1.0).


2013/10/12 Denis Kudriashov <dionisiydk at gmail.com>

> Hi
>
> 2013/10/12 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
>
>> OK Igor,
>> I loaded ConfigurationOfTxText and I understand what you say:
>> - TxText spend more time in composing layout because it records each and
>> every TxSpanInterval
>> - this will later accelerate display, because no scanning is required at
>> display time
>> On the base that you compose once and display many, this is a Memory/CPU
>> trading that would not have been a good idea the 70's (birth of
>> CharacterScanner family), but is now fair.
>>
>> Even if that does not make much sense, composition (layout building) can
>> be measured with this kind of mini bench:
>>
>>
>> | text |
>> text := Compiler evaluate: (FileSystem workingDirectory parent parent
>> parent / 'text.st' ) readStream contentsOfEntireFile .
>>  MessageTally spyOn: [[100 timesRepeat: [(Paragraph new)
>>         compose: text
>>         style: TextStyle default copy
>>         from: 1
>>         in: ( 0 at 0 corner: 569 at 9999999)]] timeToRun ].
>> MessageTally spyOn: [ 100 timesRepeat: [| m |
>>     m := TxTextMorph new.
>>     m layoutStrategy: TxWrapTextStrategy new.
>>     m extent: 569 at 9999999.
>>     m newTextContents: text]]
>>
>> 95ms in revised Squeak CompositionScanner / 366ms Pharo
>> MultiCcompositionScanner / 347ms TxText
>
>
> I think it is not correct code for TxText. "text" variable contains Text
> instance which should be converted to TxModel first. TxModel is replacement
> of Text in TxText.
>
> So my benches shows that TxText works better in Pharo:
>
> text := Compiler evaluate: (FileSystem workingDirectory / 'text.st' )
> readStream contentsOfEntireFile .
>
> [100 timesRepeat: [(Paragraph new)
>         compose: text
>         style: TextStyle default copy
>         from: 1
>         in: ( 0 at 0 corner: 569 at 9999999)]] timeToRun . 236.
>
> txModel := TxModel new.
> cursor := txModel startSpan startPosition.
> cursor insert: text.
>
> [ 100 timesRepeat: [| m |
>     m := TxTextMorph new.
>     m layoutStrategy: TxWrapTextStrategy new.
>     m extent: 569 at 9999999.
>     m textModel: txModel]] timeToRun. 145.
>
> [ 100 timesRepeat: [| m |
>     m := TxTextMorph new.
>     m layoutStrategy: TxNativeLayoutStrategy new. "without wrapping"
>     m extent: 569 at 9999999.
>     m textModel: txModel]] timeToRun. 118 .
>
> But Squeak is champion:
>
> [100 timesRepeat: [(NewParagraph new)
>         compose: text
>         style: TextStyle default copy
>         from: 1
>         in: ( 0 at 0 corner: 569 at 9999999)]] timeToRun . 84.
>
> Best regards,
> Denis
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131012/d77c3d8c/attachment-0002.html>


More information about the Pharo-dev mailing list