statistics.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright Institute of Communication and Computer Systems (ICCS)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /**
  18. * @file statistics.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @date September 2012
  21. * @brief Statistics function.
  22. */
  23. #ifndef DMMLIB_STATISTICS_H_
  24. #define DMMLIB_STATISTICS_H_
  25. #include <dmmlib/config.h>
  26. #ifdef WITH_ALLOCATOR_STATS
  27. #include <inttypes.h>
  28. #include "dmmlib/dmmlib.h"
  29. #include "dmmlib/dmmstats.h"
  30. #include "locks.h"
  31. #ifdef REQUEST_SIZE_INFO
  32. /** Updates the global statistics for specific dmmlib events */
  33. #define UPDATE_GLOBAL_STATS(EVENT_TYPE, REQ_SIZE) \
  34. LOCK_GLOBAL(); \
  35. update_stats(&systemallocator.dmm_stats, EVENT_TYPE, REQ_SIZE); \
  36. UNLOCK_GLOBAL();
  37. #else /* REQUEST_SIZE_INFO */
  38. /** Updates the global statistics for specific dmmlib events */
  39. #define UPDATE_GLOBAL_STATS(EVENT_TYPE) \
  40. LOCK_GLOBAL(); \
  41. update_stats(&systemallocator.dmm_stats, EVENT_TYPE); \
  42. UNLOCK_GLOBAL();
  43. #endif /* REQUEST_SIZE_INFO */
  44. /** DMM event type enumeration */
  45. typedef enum dmm_event_type_en
  46. { MALLOC
  47. , FREE
  48. #ifdef WITH_MEMALIGN
  49. , MEMALIGN
  50. #endif /* WITH_MEMALIGN */
  51. } dmm_event_type;
  52. void update_stats
  53. ( dmmstats_t *dmm_stats
  54. , dmm_event_type event
  55. #ifdef REQUEST_SIZE_INFO
  56. , size_t mem_req
  57. #endif /* REQUEST_SIZE_INFO */
  58. );
  59. #else /* WITH_ALLOCATOR_STATS */
  60. /** Does nothing */
  61. #define UPDATE_GLOBAL_STATS(...)
  62. #endif /* WITH_ALLOCATOR_STATS */
  63. #endif /* DMMLIB_STATISTICS_H_ */