mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-08-23 15:54:47 +03:00
add _mi_stats_init to initialize the process start time
This commit is contained in:
parent
4bf6ae693a
commit
d51e33b18e
3 changed files with 10 additions and 1 deletions
|
@ -237,6 +237,7 @@ bool _mi_heap_area_visit_blocks(const mi_heap_area_t* area, mi_page_t*
|
||||||
void _mi_heap_page_reclaim(mi_heap_t* heap, mi_page_t* page);
|
void _mi_heap_page_reclaim(mi_heap_t* heap, mi_page_t* page);
|
||||||
|
|
||||||
// "stats.c"
|
// "stats.c"
|
||||||
|
void _mi_stats_init(void);
|
||||||
void _mi_stats_done(mi_stats_t* stats);
|
void _mi_stats_done(mi_stats_t* stats);
|
||||||
void _mi_stats_merge_thread(mi_tld_t* tld);
|
void _mi_stats_merge_thread(mi_tld_t* tld);
|
||||||
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from);
|
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from);
|
||||||
|
|
|
@ -709,6 +709,7 @@ void mi_process_init(void) mi_attr_noexcept {
|
||||||
_mi_verbose_message("process init: 0x%zx\n", _mi_thread_id());
|
_mi_verbose_message("process init: 0x%zx\n", _mi_thread_id());
|
||||||
|
|
||||||
mi_detect_cpu_features();
|
mi_detect_cpu_features();
|
||||||
|
_mi_stats_init();
|
||||||
_mi_os_init();
|
_mi_os_init();
|
||||||
_mi_page_map_init();
|
_mi_page_map_init();
|
||||||
mi_heap_main_init();
|
mi_heap_main_init();
|
||||||
|
|
|
@ -386,6 +386,12 @@ static void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0)
|
||||||
|
|
||||||
static mi_msecs_t mi_process_start; // = 0
|
static mi_msecs_t mi_process_start; // = 0
|
||||||
|
|
||||||
|
// called on process init
|
||||||
|
void _mi_stats_init(void) {
|
||||||
|
if (mi_process_start == 0) { mi_process_start = _mi_clock_start(); };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// return thread local stats
|
// return thread local stats
|
||||||
static mi_stats_t* mi_get_tld_stats(void) {
|
static mi_stats_t* mi_get_tld_stats(void) {
|
||||||
return &_mi_thread_tld()->stats;
|
return &_mi_thread_tld()->stats;
|
||||||
|
@ -396,9 +402,10 @@ void mi_stats_reset(void) mi_attr_noexcept {
|
||||||
mi_subproc_t* subproc = _mi_subproc();
|
mi_subproc_t* subproc = _mi_subproc();
|
||||||
if (stats != &subproc->stats) { _mi_memzero(stats, sizeof(mi_stats_t)); }
|
if (stats != &subproc->stats) { _mi_memzero(stats, sizeof(mi_stats_t)); }
|
||||||
_mi_memzero(&subproc->stats, sizeof(mi_stats_t));
|
_mi_memzero(&subproc->stats, sizeof(mi_stats_t));
|
||||||
if (mi_process_start == 0) { mi_process_start = _mi_clock_start(); };
|
_mi_stats_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from) {
|
void _mi_stats_merge_from(mi_stats_t* to, mi_stats_t* from) {
|
||||||
mi_assert_internal(to != NULL && from != NULL);
|
mi_assert_internal(to != NULL && from != NULL);
|
||||||
if (to != from) {
|
if (to != from) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue