Last active
March 30, 2022 04:17
-
-
Save jayhuang75/42096590c80960aa79b5a4d998ad621c to your computer and use it in GitHub Desktop.
token_bucket_unit_test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[test] | |
| fn test_token_bucket() { | |
| let mut cinema = TokenBucket::new(2, 10); | |
| let mut number_of_showtime:i64 = 0; | |
| let mut random_volume_of_people = rand::thread_rng(); | |
| while number_of_showtime < 10 { | |
| thread::sleep(time::Duration::from_secs_f64(2.0)); | |
| cinema.handle(random_volume_of_people.gen_range(1..10)); | |
| number_of_showtime += 1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment