Mailinglist Archive: zypp-devel (226 mails)
| < Previous | Next > |
Re: [zypp-devel] Test of boost::replace_all
- From: Josef Reidinger <jreidinger@xxxxxxx>
- Date: Tue, 22 Apr 2008 16:58:18 +0200
- Message-id: <480DFD0A.5090907@xxxxxxx>
Josef Reidinger wrote:
Another note, I test it with different size of from and to string and result is, that gsub then replace_all is faster when from expect lot of replacing.
So if replace same length strings then in-place replace all is better and if lenght is different and finding string have more occurrences then gsub and copy c'tor is better.
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
I use in some place boost function replace all. I see in zypper, that this function jano implement. So I test which is faster and also contain gsub from zypp String which is not in place (so must copy result).
Due to result I add janpo's implementation to zypp and replace all boost::replace_all
I attach test source.
Here is result (10000 and 10000000 loops):
zypper gsub boost
user time: 9
system time: 0
jano replace_all boost
user time: 7
system time: 0
boost replace_all boost
user time: 84
system time: 0
jreidinger@zofie:~/tmp/testing>
jreidinger@zofie:~/tmp/testing> g++ test.cc
jreidinger@zofie:~/tmp/testing> ./a.out
zypper gsub boost
user time: 769
system time: 0
jano replace_all boost
user time: 689
system time: 0
boost replace_all boost
user time: 8626
system time: 6
Pepa
Another note, I test it with different size of from and to string and result is, that gsub then replace_all is faster when from expect lot of replacing.
So if replace same length strings then in-place replace all is better and if lenght is different and finding string have more occurrences then gsub and copy c'tor is better.
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |