Browse Source

initial API for statistics

Ioannis Koutras 12 years ago
parent
commit
6305649113
3 changed files with 21 additions and 0 deletions
  1. 8 0
      include/dmmlib/dmmstats.h
  2. 2 0
      include/dmmlib/knobs.h
  3. 11 0
      src/statistics.c

+ 8 - 0
include/dmmlib/dmmstats.h

@@ -42,4 +42,12 @@ typedef struct dmmstats_s {
     uint32_t num_realloc; /**< Number of realloc()'s served. */
 } dmmstats_t;
 
+#ifdef REQUEST_SIZE_INFO
+/** Returns the total memory currently requested by the application. */
+size_t get_total_requested_memory(void);
+#endif /* REQUEST_SIZE_INFO */
+
+/** Returns the total memory currently allocated for the application. */
+size_t get_total_allocated_memory(void);
+
 #endif /* DMMSTATS_H */

+ 2 - 0
include/dmmlib/knobs.h

@@ -27,6 +27,8 @@
 
 #include "dmm_config.h"
 
+#include <dmmlib/dmmstats.h>
+
 /** The knobs structure of dmmlib. */
 typedef struct dmm_knobs_s {
     double sys_alloc_size; /**< The default size of the raw block. */

+ 11 - 0
src/statistics.c

@@ -69,3 +69,14 @@ void update_stats
 
 }
 
+#ifdef REQUEST_SIZE_INFO
+size_t get_total_requested_memory(void) {
+    return systemallocator.dmm_stats.total_mem_requested;
+}
+#endif /* REQUEST_SIZE_INFO */
+
+size_t get_total_allocated_memory(void) {
+    return systemallocator.dmm_stats.total_mem_allocated;
+}
+
+