File: plot-startup-data.py

package info (click to toggle)
software-center 5.1.2debian3.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,708 kB
  • sloc: python: 28,999; xml: 379; sh: 127; makefile: 28
file content (41 lines) | stat: -rwxr-xr-x 1,055 bytes parent folder | download
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
#!/usr/bin/python

# numpy is love
import numpy
import subprocess
import string
import sys

# get the filename
if len(sys.argv) > 1:
    fname = sys.argv[1]
else:
    fname = "startup-times.dat"

# read the data
revno_to_times = {}
for line in map(string.strip, open(fname)):
    if line.startswith("#") or line == "":
        continue
    try:
        (revno, time) = line.split()
        time = float(time)
    except:
        #print "invalid line: '%s'" % line
        continue
    if not revno in revno_to_times:
        revno_to_times[revno] = []
    revno_to_times[revno].append(float(time))

# generate data suitable for gnuplot
outfile = open("startup-times-gnuplot.dat", "w")
outfile.write("#revno   average-time ymin, ymax\n")
for revno, times in sorted(revno_to_times.iteritems()):
    #print revno, numpy.mean(times), numpy.std(times), numpy.var(times)
    outfile.write("%s %s %s %s\n" % (
            revno, numpy.mean(times), numpy.min(times), numpy.max(times)))
outfile.close()

# call gnuplot
subprocess.call(["gnuplot","gnuplot.plot"])