STINNER Victor added the comment:

I tried different overallocator factors:

* writer (current factor): 25% (1/4)
* writer50: 50% (1/2)
* writer100: 100% (double the buffer)

-----------------------------+-------------+----------------+---------------
Tests                        |      writer |       writer50 |      writer100
-----------------------------+-------------+----------------+---------------
list("a")                    |  588 ns (*) |         571 ns |   640 ns (+9%)
list("abc")                  |  844 ns (*) |         842 ns |         806 ns
["a"]*(100)                  |  9.3 us (*) |        9.13 us |        9.31 us
["abc"]*(100)                | 10.3 us (*) |        10.1 us |        9.86 us
["a" * 100]*(100)            | 39.1 us (*) |        38.4 us |        38.3 us
["a"]*(10**6)                | 91.2 ms (*) |        88.4 ms |        91.8 ms
["abc"]*(10**6)              |  103 ms (*) |        99.7 ms |  95.6 ms (-8%)
["a" * 100]*(10**5)          | 58.8 ms (*) | 49.4 ms (-16%) | 46.7 ms (-21%)
list(range(10**6))           |  152 ms (*) |   144 ms (-5%) |   142 ms (-7%)
list(map(str, range(10**6))) |  124 ms (*) |   112 ms (-9%) |   114 ms (-8%)
-----------------------------+-------------+----------------+---------------
Total                        |  530 ms (*) |   494 ms (-7%) |   490 ms (-8%)
-----------------------------+-------------+----------------+---------------

The best factor looks to be 50%.

With a factor lower than 25%, performances are worse :

* writer: 25% (1/4)
* writer12: 12.5% (1/8)

-----------------------------+-------------+---------------
Tests                        |      writer |       writer12
-----------------------------+-------------+---------------
list("a")                    |  588 ns (*) |         565 ns
list("abc")                  |  844 ns (*) |         814 ns
["a"]*(100)                  |  9.3 us (*) |         9.5 us
["abc"]*(100)                | 10.3 us (*) |        10.8 us
["a" * 100]*(100)            | 39.1 us (*) |  42.4 us (+8%)
["a"]*(10**6)                | 91.2 ms (*) |    96 ms (+5%)
["abc"]*(10**6)              |  103 ms (*) |   112 ms (+8%)
["a" * 100]*(10**5)          | 58.8 ms (*) | 78.5 ms (+33%)
list(range(10**6))           |  152 ms (*) |   160 ms (+5%)
list(map(str, range(10**6))) |  124 ms (*) |  137 ms (+10%)
-----------------------------+-------------+---------------
Total                        |  530 ms (*) |  583 ms (+10%)
-----------------------------+-------------+---------------

PyAccu vs PyUnicodeWriter (overallocate 50%):

-----------------------------+-------------+---------------
Tests                        |      pyaccu |       writer50
-----------------------------+-------------+---------------
list("a")                    |  713 ns (*) |  571 ns (-20%)
list("abc")                  |  984 ns (*) |  842 ns (-14%)
["a"]*(100)                  |   12 us (*) | 9.13 us (-24%)
["abc"]*(100)                | 12.6 us (*) | 10.1 us (-20%)
["a" * 100]*(100)            | 38.7 us (*) |        38.4 us
["a"]*(10**6)                |  111 ms (*) | 88.4 ms (-21%)
["abc"]*(10**6)              |  120 ms (*) | 99.7 ms (-17%)
["a" * 100]*(10**5)          | 51.9 ms (*) |        49.4 ms
list(range(10**6))           |  165 ms (*) |  144 ms (-13%)
list(map(str, range(10**6))) |  139 ms (*) |  112 ms (-19%)
-----------------------------+-------------+---------------
Total                        |  588 ms (*) |  494 ms (-16%)
-----------------------------+-------------+---------------

So using 50%, PyUnicodeWriter is always faster on Windows.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19513>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to