feat: cool profiler thingy

This commit is contained in:
Piotr Wilkin
2026-03-29 01:14:09 +01:00
parent 1e5ad35d56
commit 2e66d2c130
21 changed files with 2020 additions and 45 deletions

View File

@@ -644,6 +644,23 @@ int main(int argc, char ** argv) {
ctx_cli.ctx_server.terminate();
inference_thread.join();
// Export profiling data if profiling was enabled
if (params.profiling) {
ggml_backend_sched_t sched = llama_context_get_sched(ctx_cli.ctx_server.get_llama_context());
if (sched != nullptr) {
if (params.profiling_output.empty()) {
ggml_backend_sched_print_profiling(sched);
} else {
int ret = ggml_backend_sched_export_profiling_json(sched, params.profiling_output.c_str());
if (ret == 0) {
console::log("\nProfiling data exported to: %s\n", params.profiling_output.c_str());
} else {
console::error("\nFailed to export profiling data to: %s\n", params.profiling_output.c_str());
}
}
}
}
// bump the log level to display timings
common_log_set_verbosity_thold(LOG_LEVEL_INFO);
common_memory_breakdown_print(ctx_cli.ctx_server.get_llama_context());