home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / profiler / prf / prfutil.c < prev    next >
Text File  |  1988-11-23  |  989b  |  48 lines

  1. #include "prfifl.h"
  2. #include <dos.h>
  3. #include <stdio.h>
  4.  
  5. int PRFstart(short ip,short cs)
  6. {
  7.     if (! PRF_IsInstalled( 0x88)) {
  8.         fprintf(stderr,"PRF is not installed.\n");
  9.         return -1;
  10.     }
  11.  
  12.     fprintf(stderr, "profiling started using CS = %04x\n",cs);
  13.     
  14.     PRF_Fn( PRF_START, cs);
  15.     return 0;
  16. }
  17. int PRFstop()
  18. {         
  19.     const char *prfname = "PROFIL.OUT";
  20.     unsigned long far *lpData;
  21.     unsigned short far *tot_ints;
  22.     FILE *prf;
  23.     long i;
  24.     
  25.     long total = 0;
  26.  
  27.     lpData = (unsigned long far *) PRF_Fn( PRF_STOP );
  28.     tot_ints = (unsigned short far *)lpData;
  29.     tot_ints--;
  30.     
  31.  
  32.     prf = fopen(prfname,"w");
  33.     if(prf == NULL){
  34.         perror(prfname);
  35.         return -1;
  36.     }
  37.     fprintf(stderr,"Profiling stopped:%d total interrupts\n",*tot_ints);
  38.     fprintf(stderr,"Writing data to %s\n",prfname);
  39.  
  40.     for (i=0;i < 8192 ;i++){
  41.         if (*lpData) fprintf(prf,"%04lx %ld\n",(i << 3),*lpData);
  42.         total += *lpData++;
  43.     }     
  44.     fprintf(stderr," Total samples : %ld\n",total);
  45.     fclose(prf);
  46.     return 0;
  47. }
  48.