Revision 0bc20f3a

View differences:

measures.c
17 17
#include "measures.h"
18 18

  
19 19
static struct timeval print_tdiff = {1, 0};
20
static struct timeval print_tstartdiff = {20, 0};
21
static struct timeval print_tstart;
20 22

  
21 23
static int duplicates = 0;
22 24
static int chunks = 0;
......
31 33
  fprintf(stderr,"NeighSize,%d\n", neighsize);
32 34
}
33 35

  
34
void print_every()
36
bool print_every()
35 37
{
36 38
  static struct timeval tnext;
39
  static bool startup = true;
37 40
  struct timeval tnow;
38 41

  
39 42
  gettimeofday(&tnow, NULL);
43
  if (startup) {
44
    if (!timerisset(&print_tstart)) {
45
      timeradd(&tnow, &print_tstartdiff, &print_tstart);
46
    }
47
    if (timercmp(&tnow, &print_tstart, <)) {
48
      return false;
49
    } else {
50
      startup = false;
51
    }
52
  }
53

  
40 54
  if (!timerisset(&tnext)) {
41
    tnext = tnow;
55
    timeradd(&print_tstart, &print_tdiff, &tnext);
42 56
  }
43 57
  if (!timercmp(&tnow, &tnext, <)) {
44 58
    print_measures();
45 59
    timeradd(&tnext, &print_tdiff, &tnext);
46 60
  }
61
  return true;
47 62
}
48 63

  
49 64
/*
......
51 66
*/
52 67
void reg_chunk_duplicate()
53 68
{
54
  print_every();
69
  if (!print_every()) return;
55 70

  
56 71
  duplicates++;
57 72
}
......
61 76
*/
62 77
void reg_chunk_playout(int id, bool b, uint64_t timestamp)
63 78
{
64
  print_every();
79
  if (!print_every()) return;
65 80

  
66 81
  played += b ? 1 : 0;
67 82
  chunks++;
......
72 87
*/
73 88
void reg_neigh_size(int s)
74 89
{
75
  print_every();
90
  if (!print_every()) return;
76 91

  
77 92
  neighsize = s;
78 93
}

Also available in: Unified diff