Ignore:
Timestamp:
10/12/05 16:05:46 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
2e22a5df
Parents:
eaa5529
Message:

uses tracetime, not clocktime

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/rate/rate.c

    re81d1af r2cc187b  
    4747struct libtrace_t *trace;
    4848
    49 #define SCANSIZE 4096
    50 
    5149#define ALPHA 0.9
    52 
    53 char *buffer[SCANSIZE];
    5450
    5551static int docalc = 0;
     
    7268struct timeval current,last,diff,total;
    7369
    74 void alarmsig(int sig) {
    75         docalc++;
    76 }
    7770
    7871void secondreport() {
     
    10194        char *uri = 0;
    10295        int psize = 0;
    103         struct sigaction sigact;
    10496        struct libtrace_ip *ipptr = 0;
    10597        struct libtrace_packet_t packet;
    10698
    107         struct itimerval itv;
     99        uint32_t last_second = 0;
     100        double ts = 0.0;
    108101
    109         /*
    110          * Set up a timer to expire every second, for reporting
    111          */
    112         sigact.sa_handler = alarmsig;
    113         sigact.sa_flags = SA_RESTART;
    114         if(sigaction(SIGALRM, &sigact, NULL) < 0)
    115                 perror("sigaction");
    116         itv.it_interval.tv_sec = 1;
    117         itv.it_interval.tv_usec = 0;
    118         itv.it_value.tv_sec = 1;
    119         itv.it_value.tv_usec = 0;
    120         if (setitimer(ITIMER_REAL, &itv, NULL) < 0)
    121                 perror("setitimer");
    122102
    123103        if (argc == 2) {
     
    145125                counter[PACKETS][INSTANT] ++;
    146126
     127                ts = trace_get_seconds(&packet);
     128                if(last_second == 0) {
     129                        last_second = (int)ts;
     130                } else if (last_second < (int)ts) {
     131                        last_second = (int)ts;
     132                        docalc++;
     133                }
     134
    147135                if(docalc) {
    148136                        secondreport();
Note: See TracChangeset for help on using the changeset viewer.