Package pyforms :: Package Utils :: Module timeit |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.Utils.timeit

     1  #!/usr/bin/python
     2  # -*- coding: utf-8 -*-
     3
     4  __author__      = "Ricardo Ribeiro"
     5  __credits__     = ["Ricardo Ribeiro"]
     6  __license__     = "MIT"
     7  __version__     = "0.0"
     8  __maintainer__  = "Ricardo Ribeiro"
     9  __email__       = "ricardojvr@gmail.com"
    10  __status__      = "Development"
    11
    12
    13
    14  import time
    15  from datetime import datetime, timedelta
    16
    17 -def timeit(method):
    18          def timed(*args, **kw):
    19                  ts = time.time()
    20                  result = method(*args, **kw)
    21                  te = time.time()
    22                  time_elapsed = datetime(1,1,1) + timedelta(seconds=(te-ts) )
    23                  print("%s: %d:%d:%d:%d;%d" % (method.__name__, time_elapsed.day-1, time_elapsed.hour, time_elapsed.minute, time_elapsed.second, time_elapsed.microsecond))
    24                  return result
    25          return timed
    26