profile.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2009 Openmoko Inc.
  3. *
  4. * Authors Marek Lindner
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. /**
  22. * to profile a new function add another enum constant
  23. * and an identification string in PROF_TO_STRING
  24. */
  25. enum {
  26. PROF_add,
  27. PROF_subt,
  28. PROF_mult,
  29. PROF_div,
  30. PROF_mod,
  31. PROF_delay,
  32. PROF_memset,
  33. PROF_memcpy,
  34. PROF_memcmp,
  35. PROF_fread,
  36. PROF_sd_read,
  37. PROF_sd_cmd,
  38. PROF_sd_block,
  39. PROF_sd_data,
  40. PROF_sd_spi,
  41. PROF_sd_rcvr,
  42. PROF_COUNT, /* keep COUNT the last item */
  43. };
  44. #if PROFILER_ON
  45. #define PROF_TO_STRING \
  46. [PROF_add] = "addition", \
  47. [PROF_subt] = "subtract", \
  48. [PROF_mult] = "multipl ", \
  49. [PROF_div] = "division", \
  50. [PROF_mod] = "modulo ", \
  51. [PROF_delay] = "delay ", \
  52. [PROF_memset] = "memset ", \
  53. [PROF_memcpy] = "memcpy ", \
  54. [PROF_memcmp] = "memcmp ", \
  55. [PROF_fread] = "fread ", \
  56. [PROF_sd_read] = "sd read ", \
  57. [PROF_sd_cmd] = "sd cmd ", \
  58. [PROF_sd_block] = "sd block", \
  59. [PROF_sd_data] = "sd data ", \
  60. [PROF_sd_spi] = "sd spi ", \
  61. [PROF_sd_rcvr] = "sd rcvr ",
  62. extern struct prof_container prof_container[PROF_COUNT];
  63. #endif
  64. struct prof_container {
  65. unsigned long start_time;
  66. unsigned long total_time;
  67. unsigned long calls;
  68. };
  69. void profile_init(void);
  70. void prof_start(unsigned long index);
  71. void prof_stop(unsigned long index);
  72. void prof_print(void);
  73. void prof_demo(void);