forked from alexispapabil/thesis
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generator.py
49 lines (43 loc) · 1.53 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import os,sys,time
import random,math
def rewind(num):
r = open('rewind','r')
f = open('queue','a')
for i in range(num):
app, p, w, x, interval = r.readline().split()
f.write(app + ' ' + p + ' ' + w + ' ' + x + '\n')
f.flush()
time.sleep(int(interval))
def generator(num):
apps = ['bt','cg','ep','ft','is','lu','mg','sp']
procs = [2**i for i in range(2,7)]
classes = ['B']
walltime = {
'bt':[550, 230, 230, 80, 90, 80, 80],
'cg':[120, 90, 70, 60, 90, 150, 120],
'ep':[70, 40, 20, 10, 5, 3, 2],
'ft':[100, 70, 60, 50, 60, 50, 80],
'is':[10, 5, 5, 5, 10, 20, 10],
'lu':[260, 170, 120, 60, 45, 50, 50],
'mg':[20, 20, 10, 10, 10, 5, 5],
'sp':[640, 470, 470, 160, 160, 130, 130]
}
r = open('rewind','a')
f = open('queue','a')
for i in range(num):
app = random.choice(apps)
c = random.choice(classes)
p = random.choice(procs)
w = walltime[app][int(math.log(p,2))-1]
interval = random.randint(3,10)
r.write(app + '.' + c + '.' + 'x' + ' ' + str(p) + ' ' + str(w) + ' ' + str(0) + ' ' + str(interval) + '\n')
f.write(app + '.' + c + '.' + 'x' + ' ' + str(p) + ' ' + str(w) + ' ' + str(0) + '\n')
f.flush()
time.sleep(interval)
if __name__ == '__main__':
if os.path.exists('rewind'):
rewind(int(sys.argv[1]))
else:
generator(int(sys.argv[1]))