summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaojie Deng <xiaojie.deng@intel.com>2016-12-31 20:22:17 +0800
committerXiaojie Deng <xiaojie.deng@intel.com>2016-12-31 20:22:17 +0800
commit4f0eb52a7ecd1bfb2c2d5906d368823eb312693c (patch)
treebba4aa45e9bfb5e44cdbae12cef2fe58e5966fb3
parentf731bc4a8fc63666ae2b997e435ceb2f13752403 (diff)
downloadcaffeonacl-4f0eb52a7ecd1bfb2c2d5906d368823eb312693c.tar.gz
caffeonacl-4f0eb52a7ecd1bfb2c2d5906d368823eb312693c.tar.bz2
caffeonacl-4f0eb52a7ecd1bfb2c2d5906d368823eb312693c.zip
Fix parse_log.py and parse_log.sh for negative time duration if datetime in log across year boundary
-rwxr-xr-xtools/extra/extract_seconds.py8
-rwxr-xr-xtools/extra/parse_log.py7
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/extra/extract_seconds.py b/tools/extra/extract_seconds.py
index 591a51f9..68af69a2 100755
--- a/tools/extra/extract_seconds.py
+++ b/tools/extra/extract_seconds.py
@@ -48,11 +48,19 @@ def extract_seconds(input_file, output_file):
start_datetime = get_start_time(lines, log_created_year)
assert start_datetime, 'Start time not found'
+ last_dt = start_datetime
out = open(output_file, 'w')
for line in lines:
line = line.strip()
if line.find('Iteration') != -1:
dt = extract_datetime_from_line(line, log_created_year)
+
+ # if it's another year
+ if dt.month < last_dt.month:
+ log_created_year += 1
+ dt = extract_datetime_from_line(line, log_created_year)
+ last_dt = dt
+
elapsed_seconds = (dt - start_datetime).total_seconds()
out.write('%f\n' % elapsed_seconds)
out.close()
diff --git a/tools/extra/parse_log.py b/tools/extra/parse_log.py
index 017306b5..b47ffd0d 100755
--- a/tools/extra/parse_log.py
+++ b/tools/extra/parse_log.py
@@ -38,6 +38,7 @@ def parse_log(path_to_log):
logfile_year = extract_seconds.get_log_created_year(path_to_log)
with open(path_to_log) as f:
start_time = extract_seconds.get_start_time(f, logfile_year)
+ last_time = start_time
for line in f:
iteration_match = regex_iteration.search(line)
@@ -55,6 +56,12 @@ def parse_log(path_to_log):
# Skip lines with bad formatting, for example when resuming solver
continue
+ # if it's another year
+ if time.month < last_time.month:
+ logfile_year += 1
+ time = extract_seconds.extract_datetime_from_line(line, logfile_year)
+ last_time = time
+
seconds = (time - start_time).total_seconds()
learning_rate_match = regex_learning_rate.search(line)