| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: cp1250 -*- |
||
|
|
|||
| 2 | |||
| 3 | try: |
||
| 4 | import logging |
||
| 5 | import sys |
||
| 6 | import datetime |
||
| 7 | import time |
||
| 8 | except ImportError as err: |
||
| 9 | logging.error('Error %s import module: %s', __name__, err) |
||
| 10 | logging.exception('Exception occurred') |
||
| 11 | |||
| 12 | sys.exit(128) |
||
| 13 | |||
| 14 | __author__ = 'kszalai' |
||
| 15 | |||
| 16 | |||
| 17 | class Timing: |
||
| 18 | def __init__(self): |
||
| 19 | self.start = time.time() |
||
| 20 | |||
| 21 | def end(self): |
||
| 22 | elapsed = time.time() - self.start |
||
| 23 | # return self.__seconds_to_str(elapsed) |
||
| 24 | return str(datetime.timedelta(seconds=elapsed)) |
||
| 25 | |||
| 26 | def __seconds_to_str(self, t): |
||
| 27 | return "%d:%02d:%02d.%03d" % \ |
||
| 28 | reduce(lambda ll, b: divmod(ll[0], b) + ll[1:], |
||
| 29 | [(t * 1000,), 1000, 60, 60]) |
||
| 30 |