示例#1
0
int main( int argc, char **argv )
{
    TEST( co::base::init( argc, argv ));

    co::base::RNG rng;

    TESTLOOP( uint8_t,  0,        255 );
    TESTLOOP( uint16_t, 50,       65000 );
    TESTLOOP( uint32_t, 1<<20,    1u<<12 );
    TESTLOOP( uint64_t, 1ull<<52, 1ull<<12 );

    TESTLOOP( int8_t,  -126,       127 );
    TESTLOOP( int16_t, -32000,     32000 );
    TESTLOOP( int32_t, -1<<5,      1<<5 );
    TESTLOOP( int64_t, -1<<10,     1<<10 );

    TESTLOOP( float,  0.1f, 0.9f );
    TESTLOOP( double, 0.1,  0.9 );

    co::base::Clock clock;
    for( size_t i = 0; i < MAXLOOPS; ++i )
        rng.get< uint64_t >();
    std::cout << float( MAXLOOPS ) / clock.getTimef() << " rng/ms"
              << std::endl;

    TEST( co::base::exit( ));
    return EXIT_SUCCESS;
}
示例#2
0
文件: rng.cpp 项目: chevtche/Lunchbox
int main( int argc, char **argv )
{
    TEST( lunchbox::init( argc, argv ));

    lunchbox::RNG rng;

    TESTLOOP( uint8_t,  0,        255 );
    TESTLOOP( uint16_t, 50,       65000 );
    TESTLOOP( uint32_t, 1<<20,    1u<<12 );
    TESTLOOP( uint64_t, 1ull<<52, 1ull<<12 );

    TESTLOOP( int8_t,  -126,       127 );
    TESTLOOP( int16_t, -32000,     32000 );
    TESTLOOP( int32_t, -(1<<5),      1<<5 );
    TESTLOOP( int64_t, -(1<<10),     1<<10 );

    TESTLOOP( float,  0.1f, 0.9f );
    TESTLOOP( double, 0.1,  0.9 );

    testSpeed< uint8_t >();
    testSpeed< uint16_t >();
    testSpeed< uint32_t >();
    testSpeed< uint64_t >();
    testSpeed< servus::uint128_t >();

    TEST( lunchbox::exit( ));
    return EXIT_SUCCESS;
}