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
Improve performance during refresh #249
Conversation
I used the line_profiler to profile Here is what I get for
|
My idea was to do create the line once and scroll on the result after :
I would like to improve it so that:
|
We could then cache this function. diff --git a/pgactivity/views.py b/pgactivity/views.py
index 854596f..796a206 100644
--- a/pgactivity/views.py
+++ b/pgactivity/views.py
@@ -57,6 +57,7 @@ class line_counter:
return current_value
+@functools.lru_cache(maxsize=512)
def shorten(term: Terminal, text: str, width: Optional[int] = None) -> str:
r"""Truncate 'text' to fit in the given 'width' (or term.width).
Does this improves things? |
works like a charm :)
|
The ui is slow when scrolling up/down. Profiling shows that shorten() is the culpid. This patch adds a cache on the function.
86f338f
to
8cb411d
Compare
Done with |
thanks |
Scrolling is very slow and a long press on up/down is not very manageable.