-
Notifications
You must be signed in to change notification settings - Fork 99
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
added column sorting feature on table #26
Conversation
@tyrone-wu I think you pasted the gif for the filter feature. I tried the feature locally and it's working great. The only thing I'd add functionally is to make Enter do the following when in sorting mode:
I don't think we need to add this to the footer, just make it a hidden feature for people that may want to do this due to muscle memory from other top-like apps. |
ce51c12
to
aeae1e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally this is working great. I had some questions about some design choices.
src/app.rs
Outdated
@@ -29,15 +29,20 @@ use tui_input::Input; | |||
|
|||
use crate::bpf_program::BpfProgram; | |||
|
|||
const NUM_COLUMNS: i8 = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we used to have a HEADER_COLUMNS constant in main.rs and then dropped in this PR. Can we bring that back and then ask its size? I worry that by having more than one place where we store the number of columns may lead to bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main.rs HEADER_COLUMNS
was moved into app.rs as header_columns
field. This was so that the UI doesn't have to re-concat the header text and sort symbol in the draw loop.
In the PR, app.rs handles the text headers, which also handles applying the appropriate sort symbol to the selected header column. The main.rs now just renders the header text from the header_columns
field in app.rs.
But I updated it so that the i8
const is no longer needed. It should now only rely on header_columns.len()
when getting the size.
src/bpf_program.rs
Outdated
if self.period_ns == 0 { | ||
return 0.0; | ||
} | ||
self.runtime_delta() as f64 / self.period_ns as f64 * 100.0 | ||
} | ||
|
||
pub fn update_stats(&mut self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we sort without having to cache the value? I would prefer not doing this caching unless it was absolutely necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sort is now updated without using the caching, and bpf_program.rs should now be reverted to what it previously was as well. 👍
aeae1e7
to
a626a61
Compare
Added functionality for sorting table based on a column. #2
Most of the added code is for the new sorting feature.
I modified the
BpfProgram
class with additional fields from the columns (period avg runtime, total avg runtime, events per sec, cpu time percent) so that they don't need to be computed twice when first displaying to UI, and then when sorting.I also added a
new
method for initializing aBpfProgram
object so that it doesn't take up too much lines (which was in conjunction to the additional fields).