MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / common_perf_print

Function common_perf_print

common/sampling.cpp:475–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475void common_perf_print(const struct llama_context * ctx, const struct common_sampler * gsmpl) {
476 // TODO: measure grammar performance
477
478 const double t_sampling_ms = gsmpl ? 1e-3*gsmpl->t_total_us : 0;
479
480 llama_perf_sampler_data data_smpl;
481 llama_perf_context_data data_ctx;
482
483 memset(&data_smpl, 0, sizeof(data_smpl));
484 memset(&data_ctx, 0, sizeof(data_ctx));
485
486 if (gsmpl) {
487 auto & data = data_smpl;
488
489 data = llama_perf_sampler(gsmpl->chain);
490
491 // note: the sampling time includes the samplers time + extra time spent in common/sampling
492 LOG_INF("%s: sampling time = %10.2f ms\n", __func__, t_sampling_ms);
493 LOG_INF("%s: samplers time = %10.2f ms / %5d tokens\n", __func__, data.t_sample_ms, data.n_sample);
494 }
495
496 if (ctx) {
497 auto & data = data_ctx;
498
499 data = llama_perf_context(ctx);
500
501 const double t_end_ms = 1e-3 * ggml_time_us();
502
503 const double t_total_ms = t_end_ms - data.t_start_ms;
504 const double t_unacc_ms = t_total_ms - (t_sampling_ms + data.t_p_eval_ms + data.t_eval_ms);
505 const double t_unacc_pc = 100.0 * t_unacc_ms / t_total_ms;
506
507 LOG_INF("%s: load time = %10.2f ms\n", __func__, data.t_load_ms);
508 LOG_INF("%s: prompt eval time = %10.2f ms / %5d tokens (%8.2f ms per token, %8.2f tokens per second)\n",
509 __func__, data.t_p_eval_ms, data.n_p_eval, data.t_p_eval_ms / data.n_p_eval, 1e3 / data.t_p_eval_ms * data.n_p_eval);
510 LOG_INF("%s: eval time = %10.2f ms / %5d runs (%8.2f ms per token, %8.2f tokens per second)\n",
511 __func__, data.t_eval_ms, data.n_eval, data.t_eval_ms / data.n_eval, 1e3 / data.t_eval_ms * data.n_eval);
512 LOG_INF("%s: total time = %10.2f ms / %5d tokens\n", __func__, (t_end_ms - data.t_start_ms), (data.n_p_eval + data.n_eval));
513 LOG_INF("%s: unaccounted time = %10.2f ms / %5.1f %% (total - sampling - prompt eval - eval) / (total)\n", __func__, t_unacc_ms, t_unacc_pc);
514 LOG_INF("%s: graphs reused = %10d\n", __func__, data.n_reused);
515
516 common_memory_breakdown_print(ctx);
517 }
518}
519
520struct llama_sampler * common_sampler_get(const struct common_sampler * gsmpl) {
521 if (!gsmpl) {

Callers 7

sigint_handlerFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

llama_perf_samplerFunction · 0.85
llama_perf_contextFunction · 0.85
ggml_time_usFunction · 0.85

Tested by 2

mainFunction · 0.68
mainFunction · 0.68