source: tbroadcast/HEAD/scripts/generateGantt@ 247

Last change on this file since 247 was 247, checked in by garonne, 19 years ago

Ajout du script generateGantt

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/usr/bin/env python
2
3import os
4import sys
5import time
6import string
7
8if __name__ == '__main__':
9 file = sys.argv[1]
10 f = open (file)
11 lines = f.readlines()
12 f.close ()
13 total = len(lines)
14 min = time.time()
15 max = 0.0
16 for line in lines:
17 package, start, end = string.split(line)
18 #print float(end)-float(start)
19 if float(start)< min:
20 min = float(start)
21 if float(end)> max:
22 max = float(end)
23
24 packages = {}
25 for line in lines:
26 package, start, end = string.split(line)
27 packages[package] = {'start': float(start)-min , 'end':float(end)-min}
28
29 deb = 0.0
30 index = 0
31 step = 0.01
32 i = float(max)-float(min)
33 done = list()
34 start = list()
35 while i>0:
36 for package in packages:
37 if not package in done:
38 if packages[package]['end']>i:
39 index = index + 1
40 packages[package]['index']= index
41 done.append(package)
42 print i,index, package
43 if not package in start:
44 if packages[package]['start']> i:
45 index = index - 1
46 start.append(package)
47 #print i, 'start', package, packages[package]['start'], packages[package]['end'], packages[package]['end']-packages[package]['start']
48 i = i-step
49
50 y = 0
51 for package in packages:
52 if packages[package]['index'] > y:
53 y = packages[package]['index']
54
55 f = open ("gantt.dat", "w+")
56 for index in xrange(total+1):
57 for package in packages:
58 if packages[package]['index'] == index:
59 line = str(packages[package]['index'])+'\t'+str(packages[package]['start'])+'\t'+ str(packages[package]['end'])+'\n'
60 f.write (line)
61 f.close ()
62
63# f = open ("gantt.dat", "w+")
64# index = 1
65# for line in lines:
66# package, start, end = string.split(line)
67# f.write (str(index)+ ' ' + str(float(start)-min)+ ' ' + str(float(end)-min) + '\n')
68# index = index + 1
69# f.close ()
70
71 content= '''
72 ops
73 opt nsta
74 Total = %s
75 v/cre y([Total]) r
76 v/cre x1([Total]) r
77 v/cre x2([Total]) r
78 v/read y,x1,x2 gantt.dat
79
80 deb = 0.0
81 max = %s
82 totaly = %s
83 set NDVY [Totaly].15
84 NULL [deb] [max] 1 [Totaly]
85 SET BORD 1
86 SET FAIS 1
87 SET PLCI 2
88 SET FACI 3
89 *HISTOGRAM/CREATE/2DHISTO 1 'Gannt chart' 0 10000 [max] 0 0 [Total]
90 SET BORD 1
91 SET FAIS 1
92 SET PLCI 2
93 SET FACI 3
94
95 DO i= 1,[Total]
96 y2 = y([i])+0.5
97 GRAPHICS/PRIMITIVES/BOX x1([i]) x2([i]) y([i]) [y2]
98 ENDDO
99 GRAPHICS/HPLOT/ATITLE 'Time(s)' 'Total number of parallel execution' ! 220
100 cps
101 '''%(str(total), str(float(max)-float(min)), str(y))
102 f = open ("gantt.kumac", "w+")
103 f.write (content)
104 f.close ()
105
106 f = open ("exec.kumac", "w+")
107 f.write ("\n\n kumac/"+string.lower(Site)+".kumac")
108 f.close ()
109
110 status, output = commands.getstatusoutput ("paw<exec.kumac")
111# status, output = commands.getstatusoutput (cmd)
112#
113#
114#
115# for package in packages:
116# #print packages[package]['start'], packages[package]['end']
117# concurent = list()
118# for pack in packages:
119# if (packages[package]['start'] < packages[pack]['start'] and packages[pack]['start'] < packages[package]['end'])\
120# or (packages[package]['start'] < packages[pack]['end'] and packages[pack]['end'] < packages[package]['end']):
121# concurent.append (pack)
122# packages[package]['concurent'] = concurent
123#
124# total = 0
125# for package in packages:
126# if len(packages[package]['concurent'])> total:
127# total = len(packages[package]['concurent'])
128# if not packages[package].has_key('index'):
129# index = 1
130# for pack in packages[package]['concurent']:
131# if packages[package]['end']<packages[pack]['end']:
132# index = index + 1
133# packages[package]['index'] = index
134#
Note: See TracBrowser for help on using the repository browser.