Example #1
0
def timeit(name, fmt='{name} ({htime})', header=None):
    """Context Manager which prints the time it took to run code block."""
    if header is not None:
        print header
    b4 = time()
    yield
    sec = time() - b4
    if sec < 60:
        ht = '%.4f sec' % sec
    else:
        ht = htime(sec)
    print >> stderr, fmt.format(name=name, htime=ht, sec=sec)
Example #2
0
def timeit(name, fmt='{name} ({htime})', header=None):
    """Context Manager which prints the time it took to run code block."""
    if header is not None:
        print header
    b4 = time()
    yield
    sec = time() - b4
    if sec < 60:
        ht = '%.4f sec' % sec
    else:
        ht = htime(sec)
    print >> stderr, fmt.format(name=name, htime=ht, sec=sec)
Example #3
0
def timeit(msg="%.4f seconds", header=None):
    """Context Manager which prints the time it took to run code block."""
    if header is not None:
        print header
    b4 = time()
    yield

    t = time() - b4
    ht = htime(t)
    if t < 60:
        ht = t
    try:
        print msg % ht
    except TypeError:
        print msg, ht
Example #4
0
def timeit(msg="%.4f seconds", header=None):
    """Context Manager which prints the time it took to run code block."""
    if header is not None:
        print header
    b4 = time()
    yield

    t = time() - b4
    ht = htime(t)
    if t < 60:
        ht = t
    try:
        print msg % ht
    except TypeError:
        print msg, ht
Example #5
0
done = []
running = []
for x in map(path, argv[1:]):
    try:
        start = parse((x / 'start').text())
    except (OSError, IOError):
        continue  # didn't run on the grid.

    try:
        t = parse((x / 'finish').text()) - start
        done.append([t, x])

    except (OSError, IOError):
        running.append([start, x])

print
print magenta % 'Done'
print magenta % '======================================'
done.sort()
for t, x in done:
    print green % x, htime(t.seconds)

print
print magenta % 'Running'
print magenta % '======================================'
running.sort()
for t, x in running:
    print green % x, t, htime(
        (t.now() - t.replace(tzinfo=None)).total_seconds())