[Performance] #printString and Array ... (Example: LRUCache)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Performance] #printString and Array ... (Example: LRUCache)

marcel.taeumel (old)
Hi, there!

c := LRUCache someInstance.
(c instVarNamed: #map) size.  "47"
[(c instVarNamed: #head) printString size] timeToRun. "1825"

If this cache grows, #printString gets very slow.

c := LRUCache allInstances first.
(c instVarNamed: #map) size. "4952"
[(c instVarNamed: #head) printString size] timeToRun. "Well..."

Any ideas how to fix that?

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: [Performance] #printString and Array ... (Example: LRUCache)

Bert Freudenberg
On 19.01.2015, at 11:07, Marcel Taeumel <[hidden email]> wrote:

>
> Hi, there!
>
> c := LRUCache someInstance.
> (c instVarNamed: #map) size.  "47"
> [(c instVarNamed: #head) printString size] timeToRun. "1825"
>
> If this cache grows, #printString gets very slow.
>
> c := LRUCache allInstances first.
> (c instVarNamed: #map) size. "4952"
> [(c instVarNamed: #head) printString size] timeToRun. "Well..."
>
> Any ideas how to fix that?
>
> Best,
> Marcel
Nodes should get their own class, not be 4-element Arrays.

- Bert -






smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Performance] #printString and Array ... (Example: LRUCache)

Levente Uzonyi-2
In reply to this post by marcel.taeumel (old)
It's because I wanted the changes to be minimal, so I kept the use of
Arrays in LRUCache.
The head variable points to a circular array structure (a circular
doubly-linked list), so the only thing that stops infinite recursion is
the 50k character limit in #printString.
As Bert suggested, this recursion in printing can be avoided by using a
custom class for the list nodes.

Levente

On Mon, 19 Jan 2015, Marcel Taeumel wrote:

> Hi, there!
>
> c := LRUCache someInstance.
> (c instVarNamed: #map) size.  "47"
> [(c instVarNamed: #head) printString size] timeToRun. "1825"
>
> If this cache grows, #printString gets very slow.
>
> c := LRUCache allInstances first.
> (c instVarNamed: #map) size. "4952"
> [(c instVarNamed: #head) printString size] timeToRun. "Well..."
>
> Any ideas how to fix that?
>
> Best,
> Marcel
>
>
>
> --
> View this message in context: http://forum.world.st/Performance-printString-and-Array-Example-LRUCache-tp4800322.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>