Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Last active March 30, 2022 04:17
Show Gist options
  • Select an option

  • Save jayhuang75/42096590c80960aa79b5a4d998ad621c to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/42096590c80960aa79b5a4d998ad621c to your computer and use it in GitHub Desktop.
token_bucket_unit_test
#[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