Changeset 1973

Show
Ignore:
Timestamp:
04/11/08 15:00:08 (8 months ago)
Author:
aturner
Message:

add support for rounding timespec's to usec accuracy for non-absolute timing
methods refs #41

Location:
features/performance/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • features/performance/src/common/timer.h

    r1971 r1973  
    6060        tvp->tv_sec = time;                     \ 
    6161        tvp->tv_usec = (time - tvp->tv_sec) * 100000; \ 
    62     } while (0); 
     62    } while (0) 
    6363#endif 
    6464 
     
    7575    (tv)->tv_usec = (ts)->tv_nsec / 1000; } 
    7676#endif 
     77 
     78#ifndef ROUND_TIMESPEC_TO_MICROSEC(ts) 
     79#define ROUND_TIMESPEC_TO_MICROSEC(ts)       \ 
     80    do {                                        \ 
     81        (ts)->tv_nsec = (lroundf((float)(ts)->tv_nsec / 1000) * 1000);   \ 
     82    } while (0) 
     83#endif 
     84 
     85 
    7786 
    7887/* zero out a timer */ 
  • features/performance/src/send_packets.c

    r1971 r1973  
    385385            timesclear(&nap); 
    386386        } 
     387 
     388        /* round up/down as necessary */ 
     389        if (accurate != ACCURATE_ABS_TIME) 
     390            ROUND_TIMESPEC_TO_MICROSEC(&nap); 
     391         
    387392        break; 
    388393 
     
    396401            nap.tv_sec = n; 
    397402            nap.tv_nsec = (n - nap.tv_sec)  * 1000000000; 
     403             
     404            /* round up/down as necessary */ 
     405            if (accurate != ACCURATE_ABS_TIME) 
     406                ROUND_TIMESPEC_TO_MICROSEC(&nap); 
     407 
    398408            dbgx(3, "packet size %d\t\tequals %f bps\t\tnap " TIMEVAL_FORMAT, len, n,  
    399409                nap.tv_sec, nap.tv_nsec); 
     
    458468 
    459469 
     470    /* 
     471     * Depending on the accurate method & packet rate computation method 
     472 
    460473    /*  
    461474     * We have multiple methods of sleeping, pick the right one... 
     
    492505    case ACCURATE_NANOSLEEP: 
    493506        nanosleep_sleep(nap_this_time); 
    494  
    495507        break; 
    496508        /* 
  • features/performance/src/sleep.h

    r1972 r1973  
    114114 * sleep for some time using the select() call timeout method.   This is  
    115115 * highly portable for sub-second sleeping, but only for about 1msec 
    116  * resolution. 
     116 * resolution which is pretty much useless for our needs.  Keeping it here 
     117 * for furture reference 
    117118 */ 
    118119static inline void