-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlogDurations.py
More file actions
executable file
·43 lines (35 loc) · 915 Bytes
/
logDurations.py
File metadata and controls
executable file
·43 lines (35 loc) · 915 Bytes
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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
'''
This utility reads output from scripts that do
something like this:
while true
do
somework
echo $? >> log
date >> log
done
...and shows the time it takes for each run.
I am in a Greek locale, so I had to set it up first
to read lines like this:
0
Πεμ 14 Μάρ 2013 04:06:47 μμ EET
0
Πεμ 14 Μάρ 2013 04:13:05 μμ EET
0
Πεμ 14 Μάρ 2013 04:19:24 μμ EET
0
Πεμ 14 Μάρ 2013 04:25:42 μμ EET
'''
import sys
import locale
import time
locale.setlocale(locale.LC_ALL, 'el_GR.UTF-8')
last = None
for l in open(sys.argv[1]).readlines():
if u'EET' in l.strip().decode('utf-8'):
tup = time.strptime(l.strip(), '%a %d %b %Y %I:%M:%S %p %Z')
new = time.mktime(tup)
if last:
print new - last # , '#', new, '#', l,
last = new