File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1- 6923a7f31ed6fff1ddaf00ffb8dd56311042c395
1+ 9b92c0fed7b703c61415414c69ff196e9deb11eb
Original file line number Diff line number Diff line change @@ -43,9 +43,19 @@ const SLOTS: usize = 1024; // This value can be lower if interval is short (key
4343impl Rate {
4444 /// Create a new `Rate` with the given interval.
4545 pub fn new ( interval : std:: time:: Duration ) -> Self {
46+ Rate :: new_with_estimator_config ( interval, HASHES , SLOTS )
47+ }
48+
49+ /// Create a new `Rate` with the given interval and Estimator config with the given amount of hashes and columns (slots).
50+ #[ inline]
51+ pub fn new_with_estimator_config (
52+ interval : std:: time:: Duration ,
53+ hashes : usize ,
54+ slots : usize ,
55+ ) -> Self {
4656 Rate {
47- red_slot : Estimator :: new ( HASHES , SLOTS ) ,
48- blue_slot : Estimator :: new ( HASHES , SLOTS ) ,
57+ red_slot : Estimator :: new ( hashes , slots ) ,
58+ blue_slot : Estimator :: new ( hashes , slots ) ,
4959 red_or_blue : AtomicBool :: new ( true ) ,
5060 start : Instant :: now ( ) ,
5161 reset_interval_ms : interval. as_millis ( ) as u64 , // should be small not to overflow
You can’t perform that action at this time.
0 commit comments