[Patch] Use std::search in string::find
Dhruv Matani
dhruvbird@gmx.net
Sat Jun 12 09:45:00 GMT 2004
Hi,
You might also want to patch rfind, while you are at it. Included is a
function rr_find, that attempts to emulate rfind, and also the timings
for that function relative to string::rfind.
On Sat, 2004-06-12 at 01:46, Paolo Carlini wrote:
> Hi,
>
> the below is what I have implemented and tested on x86 and x86-64.
>
> Interestingly for the new performance testcase the stripped code
> size does *not* change. In mainline the total time changes as
> follows on P4-2400 (always -O2):
>
> current mainline x86
> --------------------
> 22.370u 0.000s 0:22.46 99.5% 0+0k 0+0io 166pf+0w
>
> patched mainline x86
> --------------------
> 9.090u 0.000s 0:09.13 99.5% 0+0k 0+0io 168pf+0w
>
> And as follows on x86-64-2GHz:
>
> current mainline x86-64
> -----------------------
> 5.216u 0.000s 0:05.21 100.0% 0+0k 0+0io 0pf+0w
>
> patched mainline x86-64
> -----------------------
> 4.743u 0.000s 0:04.74 100.0% 0+0k 0+0io 0pf+0w
>
> In general, in these days often happens that on x86 current 3.4
> gives better results than mainline. Indeed, this happens here
> too for unpatched 3.4:
>
> current 3.4 x86
> ---------------
> 14.920u 0.010s 0:15.03 99.3% 0+0k 0+0io 162pf+0w
>
> patched 3.4 x86
> ---------------
> 9.450u 0.010s 0:09.51 99.4% 0+0k 0+0io 164pf+0w
>
> All in all, the numbers speak in favor of this approach, and,
> in case we really want to change the algorithm, we can just
> improve the one provided generically in std::search.
>
> I'll wait 'til tomorrow in case of comments.
>
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: str_find.cpp
Type: text/x-c++
Size: 3675 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040612/fd823321/attachment.bin>
-------------- next part --------------
[dhruv@localhost test]$ ./str_find
Searching for: aabbaabbc*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.13 seconds.
42
Time taken: 0.14 seconds.
42
Searching for: aabbb*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.26 seconds.
37
Time taken: 0.43 seconds.
37
Searching for: xd*** in: aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy
Time taken: 0.31 seconds.
10
Time taken: 1.32 seconds.
10
Searching for: very*** in: dhruv is a very very good boy ;-)
Time taken: 0.14 seconds.
16
Time taken: 0.47 seconds.
16
Searching for: bad*** in: dhruv is a very very good boy ;-)
Time taken: 0.22 seconds.
4294967295
Time taken: 0.99 seconds.
4294967295
Searching for: extra irritating*** in: dhruv is a very very good boy ;-)
Time taken: 0.18 seconds.
4294967295
Time taken: 0.59 seconds.
4294967295
Searching for: this is a very long sentence*** in: this is a very long sentence this is a very this is a verty this is a very this is a very long sentenc
Time taken: 0.93 seconds.
0
Time taken: 2.5 seconds.
0
More information about the Libstdc++
mailing list