X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Fformat%2Fbenchmark%2Fbench_format.cpp;h=64e114b2d443b41127abd97f534e4d626a23ba58;hb=b32b81446b3b05102be0267e79203f59329c1d97;hp=f8b7443ad14c3043d69c08602157c2ba9b4e8fc2;hpb=215dd7151453fae88e6f968c975b6ce309d42dcf;p=ceph.git diff --git a/ceph/src/boost/libs/format/benchmark/bench_format.cpp b/ceph/src/boost/libs/format/benchmark/bench_format.cpp index f8b7443ad..64e114b2d 100644 --- a/ceph/src/boost/libs/format/benchmark/bench_format.cpp +++ b/ceph/src/boost/libs/format/benchmark/bench_format.cpp @@ -11,7 +11,7 @@ // several suggestions from Jens Maurer // ------------------------------------------------------------------------------ -// bench_variants.cc : do the same task, with snprintf, stream, and format +// bench_variants.cc : do the same task, with sprintf, stream, and format // and compare their times. // This benchmark is provided purely for information. @@ -29,20 +29,10 @@ #include #include // floor #include +#include #include -//#define knelson - -#ifdef knelson -namespace KNelson { -#include "boost/format3.hpp" -} -#endif - - - - // portable /dev/null stream equivalent, by James Kanze, http://www.gabi-soft.de class NulStreambuf : public std::streambuf { @@ -91,6 +81,8 @@ int NulStreambuf::overflow( int c ){ // ------------------------------------------------------------------------------------- +namespace benchmark { + static int NTests = 300000; //static std::stringstream nullStream; @@ -104,7 +96,8 @@ static const int arg3=23; static const std::string res = "0x0017 4.5230000000E+01 12.34 +0023 \n"; //static const std::string res = "23.0000 4.5230000000E+01 12.34 23 \n"; -void test_snprintf(); + +void test_sprintf(); void test_nullstream(); void test_opti_nullstream(); void test_parsed_once_format(); @@ -113,52 +106,15 @@ void test_format(); void test_try1(); void test_try2(); -#ifdef knelson -void test_format3(); -#endif - -int main(int argc, char * argv[]) { - using namespace boost; - using namespace std; - const string::size_type npos = string::npos; - - string choices=""; - if(1 bufr; + bufr.reserve(4000); + char *buf = &bufr[0]; + + // Check that sprintf is Unix98 compatible on the platform : sprintf(buf, fstring.c_str(), arg1, arg2, arg3); if( strncmp( buf, res.c_str(), res.size()) != 0 ) { cerr << endl << buf; @@ -364,25 +320,37 @@ void test_format() << ", = " << t / tstream << " * nullStream \n"; } - -#ifdef knelson -void test_format3() -{ - using namespace std; - boost::io::basic_oaltstringstream oss; - oss << KNelson::boost::format(fstring.c_str(), arg1, arg2, arg3); - if(oss.str() != res ) { - cerr << endl << oss.str(); - } +} // benchmark - boost::timer chrono; - for(int i=0; i