|
Boost : |
From: =??B?Smn47SBQYWxl6GVr?= (jpalecek_at_[hidden])
Date: 2008-07-05 04:09:55
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk