-
Notifications
You must be signed in to change notification settings - Fork 71
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 429: Implement ItemsPerSecond #577
Conversation
src/graph.rs
Outdated
|
||
fn initialize_or_increment(&mut self, key: &str, second: usize, value: u32) -> u32 { | ||
if !self.0.contains_key(key) { | ||
self.0.insert(key.to_string(), TimeSeries::new()); |
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.
Maybe use the insert function here?
src/graph.rs
Outdated
} | ||
|
||
fn initialize_or_increment(&mut self, key: &str, second: usize, value: u32) -> u32 { | ||
if !self.0.contains_key(key) { |
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.
Maybe adding that as a helper function and using here, would make sense, too?
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.
Needs some discussion
@LionsAd Thanks for the review, I pushed a new commit with the suggested fixes |
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.
Looks great, I think we can remove one more line, but then it's RTBC
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.
RTBM!
Solves this issue: #429
This PR creates a new struct
ItemsPerSecond
and some accompanying methods that encapsulate the logic of the underlying hash map.Note:
I had to use
#[allow(dead_code)]
because for some reason the compiler would complain about dead code, even though the code is being used.