File: timeformat-results.txt

c:\MARKS-STUFF\Code\timeformat> timeformat.py
================================================================================
3.3.4 (v3.3.4:7ff62415e426, Feb 10 2014, 18:13:51) [MSC v.1600 64 bit (AMD64)]

--------------------------------------------------------------------------------
py -3 -m timeit -n 10000 -r 5 "s = '{0:}, {1:}, {2:}, {3:}'  .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 3.67 usec per loop

py -3 -m timeit -n 10000 -r 5 "s = '{:d}, {}, {}, {:f}'      .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 3.66 usec per loop

py -3 -m timeit -n 10000 -r 5 "s = '{:d}, {:<6s}, {}, {:.2f}'.format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 3.81 usec per loop

--------------------------------------------------------------------------------
py -3 -m timeit -n 10000 -r 5 "s = '%s, %s, %s, %s'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2.23 usec per loop

py -3 -m timeit -n 10000 -r 5 "s = '%d, %s, %s, %f'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2 usec per loop

py -3 -m timeit -n 10000 -r 5 "s = '%d, %-6s, %s, %.2f' % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2.13 usec per loop

--------------------------------------------------------------------------------
py -3 -m timeit -n 10000 -r 5 "x = ['a' + '1' + '2'          for i in range(100)]"
        10000 loops, best of 5: 4.68 usec per loop

py -3 -m timeit -n 10000 -r 5 "x = ['a{}{}'.format('1', '2') for i in range(100)]"
        10000 loops, best of 5: 44.5 usec per loop

py -3 -m timeit -n 10000 -r 5 "x = ['a%s%s' % ('1', '2')     for i in range(100)]"
        10000 loops, best of 5: 4.67 usec per loop

py -3 -m timeit -n 10000 -r 5 -s "def fmt(f, t): return f % t" "x = [fmt('a%s%s', ('1', '2')) for i in range(100)]"
        10000 loops, best of 5: 39.5 usec per loop

================================================================================
2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]

--------------------------------------------------------------------------------
py -2 -m timeit -n 10000 -r 5 "s = '{0:}, {1:}, {2:}, {3:}'  .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2.14 usec per loop

py -2 -m timeit -n 10000 -r 5 "s = '{:d}, {}, {}, {:f}'      .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2.51 usec per loop

py -2 -m timeit -n 10000 -r 5 "s = '{:d}, {:<6s}, {}, {:.2f}'.format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 2.51 usec per loop

--------------------------------------------------------------------------------
py -2 -m timeit -n 10000 -r 5 "s = '%s, %s, %s, %s'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 1.28 usec per loop

py -2 -m timeit -n 10000 -r 5 "s = '%d, %s, %s, %f'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 1.73 usec per loop

py -2 -m timeit -n 10000 -r 5 "s = '%d, %-6s, %s, %.2f' % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 1.7 usec per loop

--------------------------------------------------------------------------------
py -2 -m timeit -n 10000 -r 5 "x = ['a' + '1' + '2'          for i in range(100)]"
        10000 loops, best of 5: 4.72 usec per loop

py -2 -m timeit -n 10000 -r 5 "x = ['a{}{}'.format('1', '2') for i in range(100)]"
        10000 loops, best of 5: 37.2 usec per loop

py -2 -m timeit -n 10000 -r 5 "x = ['a%s%s' % ('1', '2')     for i in range(100)]"
        10000 loops, best of 5: 18.3 usec per loop

py -2 -m timeit -n 10000 -r 5 -s "def fmt(f, t): return f % t" "x = [fmt('a%s%s', ('1', '2')) for i in range(100)]"
        10000 loops, best of 5: 28.4 usec per loop

================================================================================
2.7.2 (341e1e3821ff, Jun 07 2012, 15:43:00)
[PyPy 1.9.0 with MSC v.1500 32 bit]

--------------------------------------------------------------------------------
C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '{0:}, {1:}, {2:}, {3:}'  .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.773 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '{:d}, {}, {}, {:f}'      .format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.772 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '{:d}, {:<6s}, {}, {:.2f}'.format(123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.847 usec per loop

--------------------------------------------------------------------------------
C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '%s, %s, %s, %s'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.627 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '%d, %s, %s, %f'     % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.582 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "s = '%d, %-6s, %s, %.2f' % (123, 'spam', [1, 2], 7.89)"
        10000 loops, best of 5: 0.531 usec per loop

--------------------------------------------------------------------------------
C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "x = ['a' + '1' + '2'          for i in range(100)]"
        10000 loops, best of 5: 0.523 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "x = ['a{}{}'.format('1', '2') for i in range(100)]"
        10000 loops, best of 5: 2.06 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 "x = ['a%s%s' % ('1', '2')     for i in range(100)]"
        10000 loops, best of 5: 0.552 usec per loop

C:\PyPy\pypy-1.9\pypy -m timeit -n 10000 -r 5 -s "def fmt(f, t): return f % t" "x = [fmt('a%s%s', ('1', '2')) for i in range(100)]"
        10000 loops, best of 5: 2.56 usec per loop

[Press Enter]



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz