5 Jul 10:08
[test] RFC: speed up BOOST_CHECK by not formatting the check description if it isn't written anywhere
From: =??B?Smn47SBQYWxl6GVr?= <jpalecek <at> web.de>
Subject: [test] RFC: speed up BOOST_CHECK by not formatting the check description if it isn't written anywhere
Newsgroups: gmane.comp.lib.boost.devel
Date: 2008-07-05 08:09:55 GMT
Subject: [test] RFC: speed up BOOST_CHECK by not formatting the check description if it isn't written anywhere
Newsgroups: gmane.comp.lib.boost.devel
Date: 2008-07-05 08:09:55 GMT
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
(Continue reading)
RSS Feed