Last active
August 29, 2015 14:17
-
-
Save ccalabro/353d48d8c577cb6e5e41 to your computer and use it in GitHub Desktop.
Determines if answer a request depending latency average
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# # http://stackoverflow.com/a/15613104/3041998 | |
import random | |
th_min = 0.8 | |
th_max = 1.6 | |
def request_ok(lat_avg, th_min, th_max): | |
return random.uniform(th_min, th_max) > lat_avg | |
i=0 | |
while i < 10: | |
lat_avg = random.uniform(0.0, 3.0) | |
print str(lat_avg) + ' --> Answer Request? --> ' + str(request_ok(lat_avg, th_min, th_max)) | |
i+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment