#include #include #include #include #include #include #include #include "boost.any.doubleSize.hpp" template< class AnyVersion , class ArgumentType > unsigned int test_copying( const ArgumentType &argument ) { unsigned int t = std::clock(); for( unsigned int i = 0 ; i < 100000 ; ++i ) { AnyVersion x( argument ); //copy from ArgumentType x = argument; x = argument; x = argument; x = argument; x = argument; } AnyVersion any_argument = argument; for( unsigned int i = 0 ; i < 100000 ; ++i ) { AnyVersion x( any_argument ); //copy from AnyVersion x = any_argument; x = any_argument; x = any_argument; x = any_argument; x = any_argument; } return std::clock() - t ; } template< class AnyVersion , class ArgumentType > unsigned int test_moving() { unsigned int t = std::clock(); for( unsigned int i = 0 ; i < 100000 ; ++i ) { AnyVersion x = ArgumentType(); //move from ArgumentType x = ArgumentType(); x = ArgumentType(); x = ArgumentType(); x = ArgumentType(); x = ArgumentType(); x = ArgumentType(); x = ArgumentType(); } for( unsigned int i = 0 ; i < 100000 ; ++i ) { AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion x = AnyVersion( ArgumentType() ); //move from AnyVersion } return std::clock() - t ; } template< class AnyVersion > unsigned int test_any_cast() //any_cast is independent from type in both versions { using boost::any_cast; unsigned int t = std::clock(); AnyVersion x = std::string(); try { for( unsigned int i = 0 ; i < 1000000 ; ++i ) { std::string y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); y = any_cast< std::string >( x ); } }catch( ... ) { std::cout<< "measure_any_cast: broken version" < void test_all( const ArgumentType &argument ) { std::cout<< " copying:"<( argument ) <( argument ) <() <() <() <() <