Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
 
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include "types.h"
5
#include <trace.h>
6
#include "util.h"
7
 
8
 
9
/* distribuzione degli spostamenti della testina */
10
 
11
#define MAXX 1000
12
#define PREC 1000
13
#define DELTA ((double)MAXX/(double)PREC)
14
 
15
#include "distr.c"
16
 
17
int dumpusr(int event, trc_user_event_t *usr)
18
{
19
  static long last=-1;
20
  long d;
21
  if (event!=TRC_USER0) return 0;
22
  if (last!=-1) {
23
    d=abs(last-usr->n);
24
    d_insert(d);
25
  }
26
  last=usr->n;
27
  return 0;
28
}
29
 
30
int dumpfunc(trc_event_t *ev)
31
{
32
  if (event_class(ev->event)==TRC_CLASS_USER) dumpusr(ev->event,&ev->x.usr);
33
  return 0;
34
}
35
 
36
int main(int argc, char *argv[])
37
{
38
  FILE *fout;
39
  int res;  
40
  if (argc!=3) {
41
    fprintf(stderr,"missing filename!\n");
42
    return -1;
43
  }
44
  d_init();
45
  res=read_trace(argv[1],dumpfunc);
46
  if (res==0) {
47
    fout=fopen(argv[2],"wt");
48
    if (fout!=NULL) {
49
      d_dump(fout);
50
      fclose(fout);
51
    } else
52
      fprintf(stderr,"can't create output file!\n");
53
  } else
54
    fprintf(stderr,"read_trace error\n");
55
 
56
  return 0;
57
}