Skip to content

Commit 830b957

Browse files
Jason LeakeJason Leake
Jason Leake
authored and
Jason Leake
committed
Don't call ax3_seconds_stats.py multiple times
1 parent 618c3ef commit 830b957

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

ax3_crunch.py

+29-28
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616
import cwa
1717
import os
1818
import sys
19-
import timeit
19+
import time
2020

2121
def get(config, section, key):
2222
if key in config[section]:
2323
return config[section][key]
2424
return None
2525

26+
def getb(config, section, key):
27+
""" Get boolean value from config file """
28+
value = get(config, section, key)
29+
if value is None:
30+
return False
31+
return bool(value)
32+
2633
def process(file, configFile):
2734

2835
config = configparser.ConfigParser()
@@ -71,41 +78,33 @@ def process(file, configFile):
7178
"rms_total",
7279
"std_dev_total"]
7380

74-
# Make sure that there are defaults
75-
76-
7781
for thisPlot in plotType:
78-
plotMinutes = ax3_plot_minutes.PlotMinutes()
79-
80-
configSection = config[thisPlot]
81-
# Defaults if not specified, even in DEFAULT section
82+
if getb(config, thisPlot, "ax3_plot_minutes"):
83+
plotMinutes = ax3_plot_minutes.PlotMinutes()
8284

83-
bcontrolfile = get(config, thisPlot, "bcontrolfile")
84-
nbcontrolfile = get(config, thisPlot, "nbcontrolfile")
85+
bcontrolfile = get(config, thisPlot, "bcontrolfile")
86+
nbcontrolfile = get(config, thisPlot, "nbcontrolfile")
8587

86-
showtime = get(config, thisPlot, "showtime")
87-
if showtime is not None:
88-
showtime = bool(showtime)
88+
showtime = getb(config, thisPlot, "showtime")
8989

90-
grid = get(config, thisPlot, "grid")
91-
if grid is not None:
92-
grid = bool(grid)
90+
grid = getb(config, thisPlot, "grid")
9391

94-
ymin = get(config, thisPlot, "ymin")
95-
if ymin is not None:
92+
ymin = get(config, thisPlot, "ymin")
93+
if ymin is not None:
9694
ymin = float(ymin)
9795

98-
ymax = get(config, thisPlot, "ymax")
99-
if ymax is not None:
100-
ymax = float(ymax)
96+
ymax = get(config, thisPlot, "ymax")
97+
if ymax is not None:
98+
ymax = float(ymax)
10199

102-
text = get(config, thisPlot, "text")
103-
# Only one config file for the baselined and nonbaselined files at the moment
104-
plotMinutes(nonBaselinedFile, nbcontrolfile,
105-
showtime, ymin, ymax, thisPlot, grid)
106-
plotMinutes(baselinedFile, bcontrolfile,
107-
showtime, ymin, ymax, thisPlot, grid)
100+
# Only one config file for the baselined and nonbaselined
101+
# files at the moment
102+
plotMinutes(nonBaselinedFile, nbcontrolfile,
103+
showtime, ymin, ymax, thisPlot, grid)
104+
plotMinutes(baselinedFile, bcontrolfile,
105+
showtime, ymin, ymax, thisPlot, grid)
108106

107+
if getb(config, thisPlot, "ax3_seconds_stat"):
109108
limit = get(config, "seconds_stat", "limit")
110109
if limit is not None:
111110
limit = float(limit)
@@ -129,7 +128,9 @@ def main():
129128
print("You need the .CWA, not the .csv", file=stderr)
130129
os.exit(0)
131130

132-
elapsed = timeit.timeit(process(filePath, controlFile))
131+
elapsed = time.time();
132+
process(filePath, controlFile)
133+
elapsed = time.time() - elapsed
133134
print(f"Elapsed tile {elapsed}")
134135

135136
if __name__ == "__main__":

crunch_default.ini

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
showtime=True
66

77
grid=True
8-
text="hello"
98

109
#controlfile=blah
1110
#bcontrolfile=blah
1211
#ymin=0.5
1312
#ymax=10
1413

14+
ax3_seconds_stat=True
15+
16+
# Set these to False to disable these scripts globally
17+
# Add entries to each section [mean_x] etc below to
18+
# enable them on a per-statistic basis
19+
ax3_plot_minutes=True
20+
1521
[mean_x]
1622
# Put non-default versions of the above settings here
1723
# e.g. ymin=-0.3

0 commit comments

Comments
 (0)