| 294 | static void mi_stat_process_info(mi_msecs_t* elapsed, mi_msecs_t* utime, mi_msecs_t* stime, size_t* current_rss, size_t* peak_rss, size_t* current_commit, size_t* peak_commit, size_t* page_faults); |
| 295 | |
| 296 | static void _mi_stats_print(mi_stats_t* stats, mi_output_fun* out0, void* arg0) mi_attr_noexcept { |
| 297 | // wrap the output function to be line buffered |
| 298 | char buf[256]; |
| 299 | buffered_t buffer = { out0, arg0, NULL, 0, 255 }; |
| 300 | buffer.buf = buf; |
| 301 | mi_output_fun* out = &mi_buffered_out; |
| 302 | void* arg = &buffer; |
| 303 | |
| 304 | // and print using that |
| 305 | mi_print_header(out,arg); |
| 306 | #if MI_STAT>1 |
| 307 | mi_stats_print_bins(stats->normal_bins, MI_BIN_HUGE, "normal",out,arg); |
| 308 | #endif |
| 309 | #if MI_STAT |
| 310 | mi_stat_print(&stats->normal, "normal", (stats->normal_count.count == 0 ? 1 : -(stats->normal.allocated / stats->normal_count.count)), out, arg); |
| 311 | mi_stat_print(&stats->large, "large", (stats->large_count.count == 0 ? 1 : -(stats->large.allocated / stats->large_count.count)), out, arg); |
| 312 | mi_stat_print(&stats->huge, "huge", (stats->huge_count.count == 0 ? 1 : -(stats->huge.allocated / stats->huge_count.count)), out, arg); |
| 313 | mi_stat_count_t total = { 0,0,0,0 }; |
| 314 | mi_stat_add(&total, &stats->normal, 1); |
| 315 | mi_stat_add(&total, &stats->large, 1); |
| 316 | mi_stat_add(&total, &stats->huge, 1); |
| 317 | mi_stat_print(&total, "total", 1, out, arg); |
| 318 | #endif |
| 319 | #if MI_STAT>1 |
| 320 | mi_stat_print(&stats->malloc, "malloc req", 1, out, arg); |
| 321 | _mi_fprintf(out, arg, "\n"); |
| 322 | #endif |
| 323 | mi_stat_print_ex(&stats->reserved, "reserved", 1, out, arg, ""); |
| 324 | mi_stat_print_ex(&stats->committed, "committed", 1, out, arg, ""); |
| 325 | mi_stat_print(&stats->reset, "reset", 1, out, arg); |
| 326 | mi_stat_print(&stats->page_committed, "touched", 1, out, arg); |
| 327 | mi_stat_print(&stats->segments, "segments", -1, out, arg); |
| 328 | mi_stat_print(&stats->segments_abandoned, "-abandoned", -1, out, arg); |
| 329 | mi_stat_print(&stats->segments_cache, "-cached", -1, out, arg); |
| 330 | mi_stat_print(&stats->pages, "pages", -1, out, arg); |
| 331 | mi_stat_print(&stats->pages_abandoned, "-abandoned", -1, out, arg); |
| 332 | mi_stat_counter_print(&stats->pages_extended, "-extended", out, arg); |
| 333 | mi_stat_counter_print(&stats->page_no_retire, "-noretire", out, arg); |
| 334 | mi_stat_counter_print(&stats->mmap_calls, "mmaps", out, arg); |
| 335 | mi_stat_counter_print(&stats->commit_calls, "commits", out, arg); |
| 336 | mi_stat_print(&stats->threads, "threads", -1, out, arg); |
| 337 | mi_stat_counter_print_avg(&stats->searches, "searches", out, arg); |
| 338 | _mi_fprintf(out, arg, "%10s: %7zu\n", "numa nodes", _mi_os_numa_node_count()); |
| 339 | |
| 340 | mi_msecs_t elapsed; |
| 341 | mi_msecs_t user_time; |
| 342 | mi_msecs_t sys_time; |
| 343 | size_t current_rss; |
| 344 | size_t peak_rss; |
| 345 | size_t current_commit; |
| 346 | size_t peak_commit; |
| 347 | size_t page_faults; |
| 348 | mi_stat_process_info(&elapsed, &user_time, &sys_time, ¤t_rss, &peak_rss, ¤t_commit, &peak_commit, &page_faults); |
| 349 | _mi_fprintf(out, arg, "%10s: %7ld.%03ld s\n", "elapsed", elapsed/1000, elapsed%1000); |
| 350 | _mi_fprintf(out, arg, "%10s: user: %ld.%03ld s, system: %ld.%03ld s, faults: %lu, rss: ", "process", |
| 351 | user_time/1000, user_time%1000, sys_time/1000, sys_time%1000, (unsigned long)page_faults ); |
| 352 | mi_printf_amount((int64_t)peak_rss, 1, out, arg, "%s"); |
| 353 | if (peak_commit > 0) { |
no test coverage detected