mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-25 00:23:33 +03:00
Stats printing: Convert header and footer to use emitter.
This commit is contained in:
parent
27a8fe6780
commit
b646f89173
1 changed files with 14 additions and 16 deletions
30
src/stats.c
30
src/stats.c
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "jemalloc/internal/assert.h"
|
#include "jemalloc/internal/assert.h"
|
||||||
#include "jemalloc/internal/ctl.h"
|
#include "jemalloc/internal/ctl.h"
|
||||||
|
#include "jemalloc/internal/emitter.h"
|
||||||
#include "jemalloc/internal/mutex.h"
|
#include "jemalloc/internal/mutex.h"
|
||||||
#include "jemalloc/internal/mutex_prof.h"
|
#include "jemalloc/internal/mutex_prof.h"
|
||||||
|
|
||||||
|
|
@ -1289,15 +1290,17 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
emitter_t emitter;
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_init(&emitter,
|
||||||
"{\n"
|
json ? emitter_output_json : emitter_output_table, write_cb,
|
||||||
"\t\"jemalloc\": {\n");
|
cbopaque);
|
||||||
} else {
|
emitter_begin(&emitter);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_table_printf(&emitter, "___ Begin jemalloc statistics ___\n");
|
||||||
"___ Begin jemalloc statistics ___\n");
|
emitter_json_dict_begin(&emitter, "jemalloc");
|
||||||
}
|
|
||||||
|
|
||||||
|
if (json) {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, "\n");
|
||||||
|
}
|
||||||
if (general) {
|
if (general) {
|
||||||
stats_general_print(write_cb, cbopaque, json, config_stats);
|
stats_general_print(write_cb, cbopaque, json, config_stats);
|
||||||
}
|
}
|
||||||
|
|
@ -1306,12 +1309,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
||||||
unmerged, bins, large, mutex);
|
unmerged, bins, large, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
emitter_json_dict_end(&emitter); /* Closes the "jemalloc" dict. */
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_table_printf(&emitter, "--- End jemalloc statistics ---\n");
|
||||||
"\t}\n"
|
emitter_end(&emitter);
|
||||||
"}\n");
|
|
||||||
} else {
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"--- End jemalloc statistics ---\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue