Ignore:
Timestamp:
Aug 29, 2011, 7:02:47 PM (9 years ago)
Author:
sam
Message:

test: improve the benchmark code to measure a lot more half precision
number conversions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/half.cpp

    r875 r877  
    3434{
    3535    CPPUNIT_TEST_SUITE(HalfTest);
     36    CPPUNIT_TEST(test_half_from_float);
     37    CPPUNIT_TEST(test_half_makeslow);
    3638    CPPUNIT_TEST(test_half_makebits);
    37     CPPUNIT_TEST(test_half_makeslow);
    38     CPPUNIT_TEST(test_half_makefast);
    3939    CPPUNIT_TEST(test_half_is_nan);
    4040    CPPUNIT_TEST(test_half_is_inf);
     
    5757    void tearDown() {}
    5858
    59     void test_half_makebits()
    60     {
    61         for (unsigned int i = 0; i < 0x10000; i++)
    62         {
    63             half a = half::makebits(i);
    64             uint16_t b = i;
     59    void test_half_from_float()
     60    {
     61        for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++)
     62        {
     63            half a = (half)pairs[i].f;
     64            uint16_t b = pairs[i].x;
    6565            CPPUNIT_ASSERT_EQUAL(a.bits, b);
    6666        }
     
    7777    }
    7878
    79     void test_half_makefast()
    80     {
    81         for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++)
    82         {
    83             half a = half::makefast(pairs[i].f);
    84             uint16_t b = pairs[i].x;
     79    void test_half_makebits()
     80    {
     81        for (unsigned int i = 0; i < 0x10000; i++)
     82        {
     83            half a = half::makebits(i);
     84            uint16_t b = i;
    8585            CPPUNIT_ASSERT_EQUAL(a.bits, b);
    8686        }
Note: See TracChangeset for help on using the changeset viewer.