statistics.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. DEALY_LOCK(tls_allocator->edit_lock); \
  35. update_stats(&systemallocator->dmm_stats, EVENT_TYPE, REQ_SIZE); \
  36. DEALY_UNLOCK(tls_allocator->edit_lock);
  37. #else /* REQUEST_SIZE_INFO */
  38. /** Updates the global statistics for specific dmmlib events */
  39. #define UPDATE_GLOBAL_STATS(EVENT_TYPE) \
  40. DEALY_LOCK(tls_allocator->edit_lock); \
  41. update_stats(&systemallocator->dmm_stats, EVENT_TYPE); \
  42. DEALY_UNLOCK(tls_allocator->edit_lock);
  43. #endif /* REQUEST_SIZE_INFO */
  44. /** DMM event type enumeration */
  45. typedef enum dmm_event_type_en
  46. { MALLOC
  47. , FREE
  48. #ifdef WITH_REALLOC
  49. , REALLOC_LT
  50. , REALLOC_GT
  51. #endif /* WITH_REALLOC */
  52. #ifdef WITH_MEMALIGN
  53. , MEMALIGN
  54. #endif /* WITH_MEMALIGN */
  55. } dmm_event_type;
  56. void update_stats
  57. ( dmmstats_t *dmm_stats
  58. , dmm_event_type event
  59. #ifdef REQUEST_SIZE_INFO
  60. , size_t mem_req
  61. #endif /* REQUEST_SIZE_INFO */
  62. );
  63. #else /* WITH_ALLOCATOR_STATS */
  64. /** Does nothing */
  65. #define UPDATE_GLOBAL_STATS(...)
  66. #endif /* WITH_ALLOCATOR_STATS */
  67. #endif /* DMMLIB_STATISTICS_H_ */