Conversation
Only clear the index when the textview dimensions change or the text itself is cleared. Add to the index when new text is added to the view. Fixes rivo#266
Add a parameter to indicate whether the caller wants the string width. Do not calculate the string width when it is not needed
|
I've created benchmarks for writing to and drawing TextViews (submitted as #356) and compared the results before and after applying these optimizations.
|
|
So, it has gotten worse? Because |
|
Based on the benchmark results, these optimizations:
|
|
This change optimizes for large amounts of text, especially one that constantly gets appended to (displaying a tailing log). |
|
Thanks for your feedback. I've updated the tests and benchmarks to include cases where a small amount of data is written to a TextView that contains a lot of data. You can see these changes in the updated pull request I linked earlier. |
|
Any chance to have this merged? I am currently using tview for TUI for my experimental chat application and use TextView as a chat log. |
|
@tslocum, hey, since you are maintaining cview, what do you think about getting that PR in? Imo this is a good improvement. I would submit it but there are some non-trivial conflicts so I am not sure about them. |
|
I rebased it here: https://github.com/foxcpp/tview/tree/textview-opts but as I said, I am not sure if I did everything correctly. |
|
Hey @foxcpp, I only see your optimization to use TrimRightFunc in your updated branches. Were you able to review the benchmark results which seem to show these changes cause decreases in performance? |
|
@tslocum Woops, forgot to Here is the benchcmp output master vs textview-opts branch: benchcmp.txt There is a decrease in performance for Draw almost everywhere, enough to nullify my TrimRightFunc change, huh. Write gets +500% improvement for scrollable TextView, though. |
|
I believe you have the results backwards: when not wrapping text, Draw is improved 60% while Write is up to 600% slower (if old is master and new is textview-opts). |
|
Woops x2. You are right. |
|
Closing this as it's obsolete. Check out the new |
Only clear the index when the textview dimensions change or the text
itself is cleared.
Add to the index when new text is added to the view.
Fixes #266