Skip to content

Instantly share code, notes, and snippets.

@jpetazzo
Created May 25, 2012 21:40
Show Gist options
  • Save jpetazzo/2790769 to your computer and use it in GitHub Desktop.
Save jpetazzo/2790769 to your computer and use it in GitHub Desktop.
Evaluate staggering of repeated jobs depending of scheduling interval computation
#!/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