moosetechnology / Moose

MOOSE - Platform for software and data analysis.
https://moosetechnology.github.io/moose-wiki
MIT License
136 stars 34 forks source link

ROCachedLabel - improved performance with large numbers of elements #901

Closed seandenigris closed 9 years ago

seandenigris commented 9 years ago

Originally reported on Google Code with ID 901

With large numbers of elements that display strings, Roassal is quite slow.  Tracing
this down shows the main culprit is #extentFor:.  A proposed solution ROCachedLabel
is provided in attached .st file which returns a cached extentFor value.  This is nilled
out when the value of the string changes. The other variables in ROCachedLabel are
also cached, but the performance gain from these is unclear.

To test the effect of this, try the following script for both ROLabel and ROCachedLabel...

---
| rawView el count elements |
rawView := ROView new @ RODraggable.
count := 1000.
elements := (1 to: count) collect:
[   :x | 
    el := (ROElement spriteOn: x) + ROLabel "ROCachedLabel".
    el on: ROMouseLeftClick do: 
    [ :ev | 
        ev element model: (ev element model + 1).
        ev element view signalUpdate .
     ]
].
rawView addAll: elements.
1 to: count do: 
[   :x |
    rawView add: (ROEdge new from: (elements at: x) to: (elements at: (Random new nextInt:
count - x + 1))) + ROLine.
].
ROHorizontalTreeLayout on: rawView elements.
rawView open  

---

Also attached is the MessageTally report from which it was determined that #extentFor
was the problem.

Reported by benjamin.t.coman on 2013-01-10 17:50:43


seandenigris commented 9 years ago
Hi Ben,

Your change makes sense. However I do not want to be that hasty to include this class
in Roassal. The reason is that I prefer to have #extentFor: not sent when not necessary
than caching it to make it fast. However, if this works well in your case, then use
it.

Reported by alexandre.bergel on 2013-01-14 12:28:49