Josef Reidinger wrote:
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@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org