-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOneStep.py
More file actions
executable file
·68 lines (55 loc) · 1.92 KB
/
OneStep.py
File metadata and controls
executable file
·68 lines (55 loc) · 1.92 KB
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
65
66
67
68
#!/usr/bin/env python
#
# Needs option parser.
#
import sys
def pull_step(filename,outfile,step=1):
"""Pulls out the text between the *step* occurance of "Start MainLoop ... End MainLoop" """
file = open(filename,"r")
first_line = file.readline()
#We won't be matching regexp for the expense.
ProcessorNumber = first_line.split()[0]
#I don't what the start of the run to make the plot horrible.
whatIwantFromTheFirstLine = ProcessorNumber+" TIME Start Main"
outfile.write(first_line[0:len(whatIwantFromTheFirstLine)])
#Set up the main loop strings
StartString = "Start MainLoop"
StopString = "End MainLoop"
StartLine = ProcessorNumber + " TIME " + StartString
StopLine = ProcessorNumber + " TIME " + StopString
len_start = len(StartLine)
len_stop = len(StopLine)
len_proc = len(ProcessorNumber) + 6
LoopCounter=1
Reading = False
for line in file:
#if this line is a Start MainLoop
# LoopCounter++
# if LoopCounter == step, Reading=true
#if Reading=True
# put the lotion in the basket.
# If end line break.
if not Reading:
if line[len_proc:len_start] == StartString:
if LoopCounter == step:
Reading = True
time = line[len_start+1:]
outfile.write(" " + time)
LoopCounter += 1
#in a separate conditional to keep the start line.
if Reading:
outfile.write(line)
if line[len_proc:len_stop] == StopString:
break
file.close()
#end
if len(sys.argv) > 1:
output = 'all_times'
step = 3
output = open("all_files","w")
for filename in sys.argv[1:]:
pull_step(filename,output,step)
output.close()
else:
print "OneStep.py <options> <list of files>"
print "Pulls out all code between the *stepth* iteration of MainLoop"