This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ezio.melotti, jcea, loewis, pitrou, vstinner
Date 2011-12-17.20:24:43
SpamBayes Score 1.6128353e-06
Marked as misclassified No
Message-id <1324153484.48.0.638466959595.issue13624@psf.upfronthosting.co.za>
In-reply-to
Content
Oh, Antoine told me that I missed the -s command line argument to timeit:

$ cat bench.sh 
echo -n "ASCII: "
./python -m timeit -s 'x="A"*50000' 'x.encode("utf-8")'
echo -n "UCS-1: "
./python -m timeit -s 'x="\xe9"*50000' 'x.encode("utf-8")'
echo -n "UCS-2: "
./python -m timeit -s 'x="\u20ac"*50000' 'x.encode("utf-8")'
echo -n "UCS-4: "
./python -m timeit -s 'x="\U0010FFFF"*50000' 'x.encode("utf-8")'

Python 3.2:

ASCII: 10000 loops, best of 3: 28.2 usec per loop
UCS-1: 10000 loops, best of 3: 59.1 usec per loop
UCS-2: 10000 loops, best of 3: 88.8 usec per loop
UCS-4: 1000 loops, best of 3: 254 usec per loop

Python 3.3:

ASCII: 1000000 loops, best of 3: 2.01 usec per loop
UCS-1: 10000 loops, best of 3: 95.8 usec per loop
UCS-2: 1000 loops, best of 3: 201 usec per loop
UCS-4: 10000 loops, best of 3: 151 usec per loop

The results look to be similar.
History
Date User Action Args
2011-12-17 20:24:44vstinnersetrecipients: + vstinner, loewis, jcea, pitrou, ezio.melotti
2011-12-17 20:24:44vstinnersetmessageid: <1324153484.48.0.638466959595.issue13624@psf.upfronthosting.co.za>
2011-12-17 20:24:43vstinnerlinkissue13624 messages
2011-12-17 20:24:43vstinnercreate