Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag scroll bar in a medium-sized string is too slow. #34

Open
tinchodias opened this issue Jul 26, 2023 · 0 comments
Open

Drag scroll bar in a medium-sized string is too slow. #34

tinchodias opened this issue Jul 26, 2023 · 0 comments

Comments

@tinchodias
Copy link
Collaborator

Evaluate this script, then drag the scroll bar a few seconds.

editor := AlbEditorElement new.
editor text: (String loremIpsum: 50000) asRopedText.

vscrollBar := BlVerticalScrollbarElement new.
vscrollBar constraintsDo: [ :c |
	c ignoreByLayout.
	c ignored horizontal alignRight ].
vscrollBar attachTo: editor infinite.

vscrollBar thumb
	when: BlDragStartEvent do: [ :evt |
		profiler := AndreasSystemProfiler new.
		profiler startProfiling ];
	when: BlDragEndEvent do: [ :evt |
		profiler stopProfiling.
		profiler doReport ].

space := BlSpace new.
space root addChild: editor.
space root addChild: vscrollBar.
space extent: 300@900.
space show.

This shows a profiler report in text, from where I focus on:

[[[                                                  68.4 (3,493)  AlbTextEditorLineSegmentHolder  pieceForElemen...ent:ifAbsent:
[[[                                                    67.4 (3,441)  AlbTextEditorLineSegmentPieceMap  pieceForElemen...ent:ifAbsent:
[[[                                                      56.800000000000004 (2,900)  Dictionary  associations
[[[                                                        |56.800000000000004 (2,900)  Array class  new:streamContents:
[[[                                                        |  43.5 (2,221)  WriteStream class [PositionableStream class]  on:
[[[                                                        |  12.5 (638)  Dictionary  associations
[[[                                                        |    12.4 (633)  Dictionary  associationsDo:
[[[                                                        |      11.8 (603)  Array [SequenceableCollection]  do:
[[[                                                        |        7.800000000000001 (398)  Dictionary  associationsDo:

68% of time is spent searching on the values of dictionaries (i.e. not searching a key, a scenario where Dictionaries perform better... it's searching among the values).

Even worse, all this calculation is part of answering AlbPrimarySelectionElement>>#selectionRectangles. When I logged the result, it was always an empty array!!!

So, 68% of time while dragging the scroll bar it is used in obtaining again and again an empty collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant