profile.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* $Id$
  2. * MegaZeux
  3. *
  4. * Copyright (C) 1996 Greg Janson
  5. * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef __PROFILE_H
  22. #define __PROFILE_H
  23. #ifdef PROFILE
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. void PROFILING_ON(void);
  28. void PROFILING_OFF(void);
  29. char REGISTER_FUNC(char far *name);
  30. void SELECT_FUNC(char which);
  31. void POP_FUNC(void);
  32. void PROFILING_SUMMARY(void);
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #define profiling_on() PROFILING_ON()
  37. #define profiling_off() PROFILING_OFF()
  38. #define enter_func(a) \
  39. static int _xqz=0;\
  40. if(!_xqz) _xqz=REGISTER_FUNC(a);\
  41. SELECT_FUNC(_xqz)
  42. #define enter_funcn(a,n) \
  43. static int _xqz##n=0;\
  44. if(!_xqz##n) _xqz##n=REGISTER_FUNC(a);\
  45. SELECT_FUNC(_xqz##n)
  46. #define exit_func() POP_FUNC()
  47. #define profiling_summary() PROFILING_SUMMARY()
  48. #define MAX_REG 50
  49. #define STACK_SIZE 50
  50. extern char reg_funcs[MAX_REG][30];
  51. extern char next_reg;
  52. extern long func_clicks[MAX_REG];
  53. extern long total_clicks;
  54. extern char func_stack[STACK_SIZE];
  55. extern char curr_stack_pos;
  56. #else
  57. #define profiling_on();
  58. #define profiling_off();
  59. #define enter_func(a);
  60. #define enter_funcn(a,n);
  61. #define exit_func();
  62. #define profiling_summary();
  63. #endif
  64. #endif