-#!/usr/bin/python
+#!/usr/bin/env python3
+# Note: this script is python2 and python 3 compatible.
#
# fiologparser.py
#
#
# to see per-interval average completion latency.
+from __future__ import absolute_import
+from __future__ import print_function
import argparse
import math
+from functools import reduce
def parse_args():
parser = argparse.ArgumentParser()
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %s" % (end, ', '.join(["%0.3f" % i for i in results]))
+ print("%s, %s" % (end, ', '.join(["%0.3f" % i for i in results])))
start += ctx.interval
end += ctx.interval
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %0.3f" % (end, sum(results))
+ print("%s, %0.3f" % (end, sum(results)))
start += ctx.interval
end += ctx.interval
while (start < ftime):
end = ftime if ftime < end else end
results = [ts.get_value(start, end) for ts in series]
- print "%s, %0.3f" % (end, float(sum(results))/len(results))
+ print("%s, %0.3f" % (end, float(sum(results))/len(results)))
start += ctx.interval
end += ctx.interval
end += ctx.interval
total = 0
- for i in xrange(0, len(averages)):
+ for i in range(0, len(averages)):
total += averages[i]*weights[i]
- print '%0.3f' % (total/sum(weights))
+ print('%0.3f' % (total/sum(weights)))
-class TimeSeries():
+class TimeSeries(object):
def __init__(self, ctx, fn):
self.ctx = ctx
self.last = None
f = open(fn, 'r')
p_time = 0
for line in f:
- (time, value, foo, bar) = line.rstrip('\r\n').rsplit(', ')
+ (time, value) = line.rstrip('\r\n').rsplit(', ')[:2]
self.add_sample(p_time, int(time), int(value))
p_time = int(time)
value += sample.get_contribution(start, end)
return value
-class Sample():
+class Sample(object):
def __init__(self, ctx, start, end, value):
self.ctx = ctx
self.start = start
print_all_stats(ctx, series)
else:
print_default(ctx, series)
-