[zypp-devel] Test of boost::replace_all
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
Hi, On Tue, 22 Apr 2008, 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
Yes, please. My rule of thumb regarding this topic is: "never ever use boost for anything". That's especially true for everything remotely related to doing some actual work. It tends to be 10 times slower than even naive implementations of whatever it was trying to provide. The boost authors are obsessed with templates and template meta programming and try to force everything they write into that style, without caring for performance. Ciao, Michael. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
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
participants (2)
-
Josef Reidinger
-
Michael Matz