summaryrefslogtreecommitdiff
path: root/test/jitter.c
blob: 8d66064e13033b2fe7d316613b90f9a1e705a27e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>

int main() {
  char line[256];
  unsigned long long a = 0,b;
  unsigned long long difference;
  unsigned long long mindiff = -1, maxdiff = 0;
  unsigned long long total = 0;
  int samples = 0;

  while (gets(line)) {
    sscanf(line,"%Ld",&b);
    if (a) {
      difference = b - a;
      printf("difference is %Ld\n",difference);
      if (difference > maxdiff) maxdiff = difference;
      if (difference < mindiff) mindiff = difference;
      total += difference;
      samples++;
    }
    a = b;
  }
  printf("min difference is %Ld, avg %Ld, max is %Ld\n",
         mindiff,total/samples,maxdiff);
  printf("jitter is %Ld\n",maxdiff-mindiff);
}