[test] RFC: speed up BOOST_CHECK by not formatting the check description if it isn't written anywhere

Hello, I have a test that uses many BOOST_CHECKs (~ 10 thousands or so). Running that test is very slow and I have noticed most of the time is spent by formatting the description string to be passed to check_impl, only to be ignored, because I don't want to log successful checks (and they are successful). I have improved this by using some kind of expression template for this (called lazy_output). It works like this: lazy_output is a class that implements an expression template for "x << y << z" expressions. The expression o << a << b << c << (make_lazy_output() << x << y << z) is the same as o << a << b << c << x << y << z which is similar to o << a << b << c << (wrap_stringstream().ref() << x << y << z).ref() The difference is that, in the call f(make_lazy_output() << x << y << z), the data is formatted only if f outputs them to an ostream. This reduced the time needed for running my test from ~12 minutes to ~7 minutes. There is more room for similar (but more complicated) improvements. Any comments or suggestions? Regards Jiri Palecek

Ji <jpalecek <at> web.de> writes:
Hello,
I have a test that uses many BOOST_CHECKs (~ 10 thousands or so). Running that
noticed most of the time is spent by formatting the description string to be
test is very slow and I have passed to check_impl, only to
be ignored, because I don't want to log successful checks (and they are successful).
I have improved this by using some kind of expression template for this (called lazy_output). It works like this:
Hi, Thanks you very much for the idea. I've implemented it a bit differently and extended to support manipulators. Also I've integrated it with UTF internals a bit more. Checked into svn in 47258. Regards, Gennadiy

On Jul 8, 2008, at 11:08 PM, Gennadiy Rozental wrote:
Ji <jpalecek <at> web.de> writes:
Hello,
I have a test that uses many BOOST_CHECKs (~ 10 thousands or so). Running that
noticed most of the time is spent by formatting the description string to be
test is very slow and I have passed to check_impl, only to
be ignored, because I don't want to log successful checks (and they are successful).
I have improved this by using some kind of expression template for this (called lazy_output). It works like this:
Hi,
Thanks you very much for the idea. I've implemented it a bit differently and extended to support manipulators. Also I've integrated it with UTF internals a bit more. Checked into svn in 47258.
Hi Gennadiy, Is this change http://www.boost.org/development/tests/trunk/developer/output/Sandia- intel-10-0-boost-bin-v2-libs-config-test-limits_test-test-intel- linux-10-0-debug-link-static.html related to these problems? I was gone for a while and didn't notice when these BOOST_CHECK errors began showing up. -- Noel

K. Noel Belcourt <kbelco <at> sandia.gov> writes:
Hi Gennadiy,
Is this change
http://www.boost.org/development/tests/trunk/developer/output/Sandia- intel-10-0-boost-bin-v2-libs-config-test-limits_test-test-intel- linux-10-0-debug-link-static.html
related to these problems?
This revision supposedly fixes this issue as well. Gennadiy

Hello, Gennadiy Rozental wrote:
Ji <jpalecek <at> web.de> writes:
I have a test that uses many BOOST_CHECKs (~ 10 thousands or so). Running that test is very slow and I have noticed most of the time is spent by formatting the description string to be passed to check_impl, only to be ignored, because I don't want to log successful checks (and they are successful).
I have improved this by using some kind of expression template for this (called lazy_output). It works like this: Thanks you very much for the idea. I've implemented it a bit differently and extended to support manipulators. Also I've integrated it with UTF internals a bit more. Checked into svn in 47258.
Thank you. Now, I have taken it one step further and used the same trick on the other arguments of check_impl (that is, argument values of predicate checks). I left the CHECK_BITWISE_EQUAL and CHECK_EQUAL_COLL taking plain old const char*, because they never take more than a string literal. The other checks' arguments are converted to lazy_ostream const*. Regards Jiri Palecek

Thank you. Now, I have taken it one step further and used the same trick on
Ji <jpalecek <at> web.de> writes: the other arguments of check_impl The description is always char const* - no need to wrap it. Otherwise fina change applied and committed. Gennadiy
participants (3)
-
Gennadiy Rozental
-
Ji�� Pale�ek
-
K. Noel Belcourt