Message160565
| Author |
vstinner |
| Recipients |
loewis, mark.dickinson, pitrou, python-dev, serhiy.storchaka, vstinner |
| Date |
2012年05月13日.20:10:28 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<CAMpsgwaFy6-voRqYjz14wPWsrcX9guYwbjgqCG0VXpLZ+fSkeg@mail.gmail.com> |
| In-reply-to |
<1336902865.3347.1.camel@localhost.localdomain> |
| Content |
>> When it's possible to not overallocate, the speed up is around 10% for
>> short strings (I suppose that it's much better to longer strings).
> Well, please post a benchmark for long strings, then :-)
Ok, here you have. I don't understand why results are so random. There
is no performance regression, but there are interesting speed up.
Original:
200 ns: L=10 ** 3; fmt="%s"; args="a" * L; fmt % args
370 ns: L=10 ** 4; fmt="%s"; args="a" * L; fmt % args
3.85 ms: L=10 ** 5; fmt="%s"; args="a" * L; fmt % args
334 ms: L=10 ** 6; fmt="%s"; args="a" * L; fmt % args
2.87 ms: L=10 ** 7; fmt="%s"; args="a" * L; fmt % args
23.9 ms: L=10 ** 8; fmt="%s"; args="a" * L; fmt % args
Patched:
120 ns (-40%): L=10 ** 3; fmt="%s"; args="a" * L; fmt % args
276 ns (-25%): L=10 ** 4; fmt="%s"; args="a" * L; fmt % args
3.7 ms (-4%): L=10 ** 5; fmt="%s"; args="a" * L; fmt % args
67.6 ms (-80%): L=10 ** 6; fmt="%s"; args="a" * L; fmt % args
1.38 ms (-51%): L=10 ** 7; fmt="%s"; args="a" * L; fmt % args
23.5 ms (-2%): L=10 ** 8; fmt="%s"; args="a" * L; fmt % args |
|