dkprof.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /***********************************************\
  2. ??? dkprof.c
  3. ? profiling functions
  4. ? also see perf.asm and pentium.asm
  5. \***********************************************/
  6. #include "duck_mem.h"
  7. #include "dkprof.h"
  8. #define MAX_PROFILE 15
  9. int profStarted = 0;
  10. enum PROFILESECTION {
  11. LOSSLESSDX = 0,
  12. PLANARDX,
  13. BLITME,
  14. RD_FRAME_DESC,
  15. RASTER_CONFIG,
  16. DELTA_TABLES,
  17. HANDLER_CONFIG,
  18. STRING_DECODER,
  19. STRING_DATA,
  20. TSC0,
  21. TSC1,
  22. TSC2,
  23. TSC3
  24. };
  25. PSECTION pSectionArray[MAX_PROFILE];
  26. unsigned long pentiumKiloCycles(void);
  27. #if 1
  28. /***********************************************/
  29. void tscStart(enum PROFILESECTION sel)
  30. {
  31. PSECTION *pSection;
  32. if(profStarted) {
  33. pSection = &pSectionArray[sel];
  34. pSection->pkc1 = pentiumKiloCycles();
  35. }
  36. }
  37. /***********************************************/
  38. void tscEnd(enum PROFILESECTION sel)
  39. {
  40. PSECTION *pSection;
  41. if(profStarted) {
  42. pSection = &pSectionArray[sel];
  43. pSection->pkc2 = pentiumKiloCycles();
  44. pSection->pkc2 = (pSection->pkc2 - pSection->pkc1);
  45. pSection->avgKc += pSection->pkc2;
  46. pSection->numTimes += 1;
  47. if(pSection->pkc2 < pSection->minKc)
  48. pSection->minKc = pSection->pkc2;
  49. if(pSection->pkc2 > pSection->maxKc)
  50. pSection->maxKc = pSection->pkc2;
  51. }
  52. }
  53. /***********************************************/
  54. void tscInit()
  55. {
  56. int i;
  57. for(i=0; i<MAX_PROFILE; i++) {
  58. duck_memset(&pSectionArray[i],0,sizeof(PSECTION));
  59. pSectionArray[i].minKc = 0xffffffff;
  60. }
  61. profStarted = 1;
  62. }
  63. /***********************************************/
  64. void tscUninit()
  65. {
  66. profStarted = 0;
  67. }
  68. /***********************************************/
  69. unsigned long tscProcessCounts(unsigned long *cnt, enum PROFILESECTION sel)
  70. {
  71. unsigned long rv = 0;
  72. *cnt = 0;
  73. if(profStarted) {
  74. if(pSectionArray[sel].numTimes) {
  75. rv = pSectionArray[sel].avgKc /= pSectionArray[sel].numTimes;
  76. *cnt = pSectionArray[sel].numTimes;
  77. duck_memset(&pSectionArray[sel],0,sizeof(PSECTION));
  78. pSectionArray[sel].minKc = 0xffffffff;
  79. }
  80. /* reset all vars */
  81. }
  82. return (rv);
  83. }
  84. #endif