-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Issue 163 elapsed time #167
Conversation
This elapsed time pauses during pause sections and restarts on resumption. Ongoing: - Consider a RwLock instead of a Mutex for the elapsed time and cumulative time values, as these are only written by the UI thread and read elsewhere. - Combine the cumulative time and start times into a struct for clarity. - Separate out the elapsed time from the Bandwidth, as they are separate considerations, leading to altering the rendering of the header to write bandwidth and elapsed time separately.
- Rename Bandwidth to HeaderDetails to indicate the added information it now contains. - Split the rendering function for the header into its constituent parts
A RwLock should be more performant.
The bandwidth print has a leading space, so this should have a trailing space.
Hey @Eosis, I'm glad you like bandwhich. the screenshots look great! About the tests, we use cargo insta for our snapshot testing. I should really write some basic instructions about it in the contributing guidelines - my apologies! In a nutshell, what it does is runs fake traffic through bandwhich in different scenarios and takes snapshots of the UI, comparing them to the existing snapshots. These snapshots are part of the repository as well in the "snapshots" folder by the relevant tests. When the tests fail, they create a new file with a I hope that makes sense and answers your question? |
Hi @Eosis ! I've taken a quick look at things and they are looking good! Thanks so much for opening this and welcome to Rust! @imsnif beat me to responding, but here are a couple of additional comments I had :)
|
Hi @imsnif, So I have spent a little time looking into the tests already and I think I have an understanding of what is required to fix them by manually looking at the snapshot files. Thanks for the tip about insta review, I will do that going forward instead... It is much less painful 😅 I am finding that the test failures are obivous new screen screen writes. There is a complication that the inherent differences in test run time means the exact writes may differ (sometimes they will show "00:00:01", and sometimes they will show "00:00:02"). I think we will either have to either: I think I prefer the latter of these, but would welcome any feedback. 😁 |
Hey @Eosis - because of my less than ideal availability at the moment, I think I will leave you in the capable hands of @TheLostLambda. I hope this is okay with both of you? Do feel free to ping me for anything. |
Hi @TheLostLambda! Thanks for the feedback and for the kind welcome. 😁
I agree that the suggested change would make the code for tracking the time much simpler, but as a user, I'd prefer the packet cap and parsing to stop at this point. This is coming from a resource perspective, where I am expecting to free up some processor time when I hit the pause. That's just my thoughts, though, it would be good to hear other opinions on that. 😁 |
Hi @Eosis!
I'd love to hear what you think about all of that! I'll also take a look into working around that snapshot issue with the tests, but I'm not certain what the best approach is at the moment. Hope you are well! |
- Only show the capture time on use of the utilization flag - Make colour consistent in header - Prioritize rendering of the Bandwidth over the duration - Reduce length of time description
Hey @TheLostLambda, Hope you're staying safe over there in Sheffield! It took me a little while to get back to this. I've been busy with work and living the lockdown life.
Have you had any more thoughts about working around the snapshots issue? |
Hi @Eosis! Thanks so much for the update, I didn't realize we were so nearby! I hope things are going well in Manchester as well! To address your points:
I had a play with the snapshots just now, and it's a little hacky, but I think it's the minimum-code solution, so it's not much to change if we decide on something fancier later: Additionally, I think you may need to run Thanks so much for all of your great work! |
Hey, I hope you two don't mind me chiming in on the snapshot issue. We've had to deal with this in the Sorry for interrupting! Let me know if you need anything. :) |
We now have the bandwidth data, paused status and duration in separate columns.
1, 2, or 3 sections will be used based on differing widths.
- Needed to set max number of columns to 3.
Hey @TheLostLambda, Yeah, not far at all! :)
As for the tests, I haven't looked at this again yet. I like your hacky solution as a stop gap. I'll look at the reference from @imsnif and assess the complexity in improving on the hacky way. 😁 |
Hi @Eosis! I'm really liking how this is turning out! I've given it a go and come up with a couple of thoughts:
# After a couple hours
03:14:15
# After a day and a bit
1 day, 12:42:13
# More than a day
4 days, 15:35:12 I'm open to thoughts on this though :) Here is the GIF of odd column behaviour: Thanks so much for all of the great work! As for tests, I think that either approach would work, though I may lean slightly towards the simpler Hope you are doing well! |
Now selectively printing out the duration of the capture based on calculating the exact length of the strings and the width of the terminal window. This has simplified this code substantially as well, no longer having to split the header into parts (currently we are printing to the same rect, but left and right aligned for the respective parts of the header).
Simply replacing the "1 \n" write events with "2 \n" when we check the snapshots to make them consistent. There may still be issues with timing in the tests, but can serve as a stop-gap.
Hi @TheLostLambda , I think I've addressed your feedback and finally got the CI pipeline passing. :) Have a look and let me know what you think.
|
src/main.rs
Outdated
ui.draw( | ||
paused.load(Ordering::SeqCst), | ||
dns_shown, | ||
std::time::Duration::new(131, 0), |
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 think we should probably replace this with the actual duration :)
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.
Yeah, figuring out why when resizing the window the timer changes to 02:11 were a confusing 2 minutes. ;P
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.
Opps... Sorry! 😅
Hi @Eosis! I've given it a good poke around, testing the scaling and the behaviour after some simulated days have passed and it's looking absolutely fantastic! I left one comment where we need to replace a placeholder value, but aside from that, I think it's looking perfect! If it's alright, I might spend some time tomorrow looking over the code before merging, but I'm super happy with this :) I'll also ping @imsnif to see what he thinks as well. Thank you so much for all of your hard work and I'm looking forward to merging this as soon as we get that placeholder filled in! |
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.
This looks great to me. Just left a minor comment. Good work! @TheLostLambda - feel free to merge if it looks good to you too.
pub paused: bool, | ||
} | ||
|
||
impl<'a> TotalBandwidth<'a> { | ||
impl<'a> HeaderDetails<'a> { |
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.
Hey, good call on the name change! One little thing though, could we also change the file name? Otherwise I'm afraid it might get a little confusing.
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 agree and have changed the name of the file. 👍
src/main.rs
Outdated
ui.draw( | ||
paused.load(Ordering::SeqCst), | ||
dns_shown, | ||
std::time::Duration::new(131, 0), |
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.
Yeah, figuring out why when resizing the window the timer changes to 02:11 were a confusing 2 minutes. ;P
|
||
if print_elapsed_time { | ||
self.render_elapsed_time(frame, rect, elapsed_time.as_ref().unwrap(), color); |
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.
Hah! Nice one :)
(also, feel free to reach out if there are issues or uncertainties with the merge conflicts) |
- Split the logic for determining the elapsed time into a function as it was called in different placed in main.rs.
e1615c9
to
d897e14
Compare
Conflicts: src/display/components/layout.rs src/display/ui.rs src/main.rs
Hey both, I have fixed the conflicts from the merge and am hopeful the CI will pass. 🤞 Let me know if you have any more comments. 😁 |
Awesome! If CI and everything checks out, I'll give the code a proper look tomorrow then we can get this merged! Thanks for all of your work on this! |
@imsnif Hmm, could we try restarting this Travis build? It looks like some behaviour has changed on the beta Rust build for MacOS? I can't restart the job myself unfortunately. It would be good to rule out just some one-time failure. |
@TheLostLambda - just restarted. Odd that you couldn't restart it yourself... are you logged into Travis with your Github account? If so, I'll try to see what's up with it. |
@imsnif Whoops, definitely wasn't logged in. That's my bad, I haven't used Travis before! I can see the restart option now :) |
Cool, no worries :) |
@Eosis Things are looking stellar! I went through the code and found a couple of little tweaks that could be made, but I'm happy merging with or without them. You can take a look here integrate any tweaks you like and just let me know when you are looking to merge! |
Also @Eosis - once this is merged I'm planning on issuing a new release and writing (among other things) about this feature on twitter. I'd be happy to link to your twitter if you send me a link (or I can link to your github too - as you prefer). Thanks again for your hard work! |
Thanks for the feedback @TheLostLambda. I implemented the bits in main but I think I prefer the originals in Hi @imsnif, Linking GH and twitter would be fun. My twitter handle is @RupRutledge. 😁 |
Looks excellent! Thanks for all of the hard work! Merging now! 😄 |
Hi @imsnif,
I found this project recently and think its great. I have done quite a bit of packet-snooping work in C and C++ and think it's great to see a utility like this in Rust. 😁
I've started looking into #163 as a first issue to learn more about the program and practice some Rust (new rustacean here). I think I have an implementation working, but it still needs a bit more work to get the tests passing and some cleanup.
I'd welcome some feedback and maybe some advice about getting these failing tests passing... 😅