pharo-graphics / Roassal

The Roassal Visualization Engine
MIT License
16 stars 11 forks source link

Slowdown caused by explicitRequirement #12

Closed JanBliznicenko closed 11 months ago

JanBliznicenko commented 11 months ago

In some cases, having traits with methods using explicitRequirement may cause noticable slowdown.

In case of OpenPonk, for larger diagrams, it makes a difference between completely fluent high-fps dragging of elements and ~2 FPS.

Outside OpenPonk, it does not seem to be that much of a problem as I had quite hard time finding pure roassal code that would show the issue:

example

This is the code:

|canvas boxes lines|
"Smalltalk globals select: [ :each | each isTrait and: [each name beginsWith: 'RST'  ]] thenDo: [ :each | each methods select: [ :eachMethod | eachMethod sourceCode includesSubstring: 'explicitRequirement' ] thenDo: [ :eachMethod | eachMethod removeFromSystem ] ]."

canvas := RSCanvas new.
boxes := (1 to: 100) collect: [ :i | RSBox new ].
canvas addAll: boxes.

(1 to: 100) do: [ :i | 
    (i to: 100) do: [ :j | 
        canvas add: (RSArrowedLine new from: (boxes at: i); to: (boxes at: j); withBorderAttachPoint; yourself).
        canvas add: (RSArrowedLine new from: (boxes at: j); to: (boxes at: i); withBorderAttachPoint; yourself).
     ]
].

canvas open.

Smalltalk garbageCollect.

TimeProfiler new runBlock: [ boxes do: [ :each | each translateBy: 1@1 ] ];
    open

For now, I remove the explicitRequirements methods in OpenPonk baseline.

JanBliznicenko commented 11 months ago

Joined with issue https://github.com/pharo-graphics/Roassal/issues/10