Skip to content

Instantly share code, notes, and snippets.

@ccalabro
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccalabro/353d48d8c577cb6e5e41 to your computer and use it in GitHub Desktop.
Save ccalabro/353d48d8c577cb6e5e41 to your computer and use it in GitHub Desktop.
Determines if answer a request depending latency average
#!/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