[Patch] libstdc++/22515
Paolo Carlini
pcarlini@suse.de
Sat Jul 23 11:07:00 GMT 2005
Hi,
the below fixes this performance issue with operator>> of chars (both
string and array). The solution - as usual, see the current getline anf
ignore - involves using a "bulky" algorithm, working inside the
streambuf. On the performance testcase (200 chars per line), the timings
change:
string&
=======
mainline
--------
10.840u 0.890s 0:11.78 99.5% 0+0k 0+0io 231pf+0w
mainline + patch
----------------
3.640u 0.870s 0:04.52 99.7% 0+0k 0+0io 232pf+0w
char*
=====
mainline
--------
10.010u 0.680s 0:10.73 99.6% 0+0k 0+0io 226pf+0w
mainline + patch
----------------
3.540u 0.870s 0:04.42 99.7% 0+0k 0+0io 227pf+0w
The improvement is of course smaller for shorter input lines but always
easily measurable down to 20-30 chars and never becoming a regression
also for very short inputs (< 5-10 chars).
A special feature of the standard requirements for these functions
(compared to getline and ignore, f.i.) is the use of ctype::is,
completely different for char (fast, inline, no virtual function calls)
vs wchar_t. Ultimately, that's why in my (rather extensive) experiments
during the last days, adding specializations for wchar_t too is not
profitable: only for long inputs a small improvement could be measured
and the performance actually become worse for shorter inputs (wrt the
generic solution currently in place, see istream.tcc).
An interesting project for after 4.1 branches, will be commonizing some
of the code of the optimized istream functions.
Tested x86-linux.
Paolo.
//////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_22515
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050723/fc8dcb8c/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_22515
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050723/fc8dcb8c/attachment-0001.ksh>
More information about the Libstdc++
mailing list