-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspdplot.py
executable file
·64 lines (48 loc) · 1.41 KB
/
spdplot.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
#!/usr/bin/python
'''
Created on 14/08/2013
@author: roberto DOT antolin AT forestry DOT gis.gov.uk
'''
import pylab
import sys, os
import numpy as np
def sortLists(L1, L2):
"""(list, list) -> [list, list]
Sort two list
>>> L1 = [2,1]
>>> L2 = [a,b]
>>> l1, l2 = sortLists(L1,L2)
>>> print l1, l2
[1,2], [b,a]
"""
return (list(t) for t in zip(*sorted(zip(L1, L2))))
def main():
timesFile = sys.argv[1]
path = os.path.dirname(timesFile)
cmd = os.path.basename(timesFile).split('_')[0]
numTempFiles = 0
X = np.loadtxt(timesFile, skiprows=1, usecols=[1,2], delimiter=';')
#fileName = X[:, 0]
fileSize = X[:, 0]
exeTimes = X[:, 1]
totalTime = np.sum(exeTimes)
totalSize = np.sum(fileSize)
for size in fileSize:
if size > 50.0:
numTempFiles +=1
#np.average(exeTimes)
#np.std(exeTimes)
print totalTime / 60., totalSize / 1024., totalSize*60/totalTime, numTempFiles / float(len(fileSize))
# Sorting by File Size
fileSize, exeTimes = sortLists(fileSize, exeTimes)
# Plotting a fancy chart
pylab.figure()
pylab.plot(fileSize, exeTimes)
pylab.xlabel('File sizes (Mb)')
pylab.ylabel('Time (sec)')
pylab.title('%s run times' %(cmd))
pylab.show()
pylab.savefig(path + '/' + cmd + '_times.png')
if __name__ == '__main__':
main()