[issue25318] Add _PyBytesWriter API to optimize Unicode encoders
STINNER Victor
report at bugs.python.org
Mon Oct 5 08:02:50 EDT 2015
STINNER Victor added the comment:
Result of bench.py attached to issue #25267: attached bench_utf8_result.txt.
------------------------------------------------------+-------------+---------------
Summary | utf8_before | utf8_after
------------------------------------------------------+-------------+---------------
ignore: "\udcff" * length | 7.63 us (*) | 7.91 us
ignore: "a" * length + "\udcff" | 10.7 us (*) | 10.8 us
ignore: ("a" * 99 + "\udcff" * 99) * length | 2.17 ms (*) | 2.16 ms
ignore: ("\udcff" * 99 + "a") * length | 843 us (*) | 866 us
ignore: "\udcff" + "a" * length | 10.7 us (*) | 11 us
replace: "\udcff" * length | 7.87 us (*) | 8.43 us (+7%)
replace: "a" * length + "\udcff" | 10.8 us (*) | 10.9 us
replace: ("a" * 99 + "\udcff" * 99) * length | 2.46 ms (*) | 2.46 ms
replace: ("\udcff" * 99 + "a") * length | 907 us (*) | 939 us
replace: "\udcff" + "a" * length | 10.9 us (*) | 11 us
surrogateescape: "\udcff" * length | 14.2 us (*) | 17.2 us (+21%)
surrogateescape: "a" * length + "\udcff" | 10.6 us (*) | 10.7 us
surrogateescape: ("a" * 99 + "\udcff" * 99) * length | 3.19 ms (*) | 3.4 ms (+7%)
surrogateescape: ("\udcff" * 99 + "a") * length | 1.64 ms (*) | 1.87 ms (+13%)
surrogateescape: "\udcff" + "a" * length | 10.6 us (*) | 10.7 us
surrogatepass: "\udcff" * length | 23.1 us (*) | 23.5 us
surrogatepass: "a" * length + "\udcff" | 10.7 us (*) | 10.8 us
surrogatepass: ("a" * 99 + "\udcff" * 99) * length | 4.39 ms (*) | 4.44 ms
surrogatepass: ("\udcff" * 99 + "a") * length | 2.43 ms (*) | 2.47 ms
surrogatepass: "\udcff" + "a" * length | 10.6 us (*) | 10.8 us
backslashreplace: "\udcff" * length | 65.7 us (*) | 64.3 us
backslashreplace: "a" * length + "\udcff" | 15.7 us (*) | 15 us
backslashreplace: ("a" * 99 + "\udcff" * 99) * length | 12 ms (*) | 15.9 ms (+32%)
backslashreplace: ("\udcff" * 99 + "a") * length | 11.1 ms (*) | 13.5 ms (+22%)
backslashreplace: "\udcff" + "a" * length | 16.4 us (*) | 15.1 us (-8%)
------------------------------------------------------+-------------+---------------
Total | 41.4 ms (*) | 48.3 ms (+17%)
------------------------------------------------------+-------------+---------------
----------
Added file: http://bugs.python.org/file40683/bench_utf8_result.txt
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25318>
_______________________________________
More information about the Python-bugs-list
mailing list