Created
May 25, 2012 21:40
-
-
Save jpetazzo/2790769 to your computer and use it in GitHub Desktop.
Evaluate staggering of repeated jobs depending of scheduling interval computation
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 | |
import random | |
jobs = [ 10, 10, 10, 10, 10, 5, 5, 5, 5, 5 ] | |
tmax = 200 | |
slots = tmax*[0] | |
def next_time_fixed(now, job): | |
return now+job | |
def next_time_random90(now, job): | |
return now + job - 0.1*job*random.random() | |
next_time = next_time_random90 | |
for job in jobs: | |
now=0 | |
while now<tmax: | |
slots[int(now)] += 1 | |
now += next_time(now, job) | |
print slots | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment