pub struct PerfContextData { /* private fields */ }Expand description
A wrapper around llama_perf_context_data.
Implementations§
Source§impl PerfContextData
impl PerfContextData
Sourcepub fn new(
t_start_ms: f64,
t_load_ms: f64,
t_p_eval_ms: f64,
t_eval_ms: f64,
n_p_eval: i32,
n_eval: i32,
) -> Self
pub fn new( t_start_ms: f64, t_load_ms: f64, t_p_eval_ms: f64, t_eval_ms: f64, n_p_eval: i32, n_eval: i32, ) -> Self
Create a new PerfContextData.
let timings = PerfContextData::new(1.0, 2.0, 3.0, 4.0, 5, 6);
assert_eq!(timings.t_load_ms(), 2.0);
assert_eq!(timings.t_p_eval_ms(), 3.0);
assert_eq!(timings.t_eval_ms(), 4.0);
assert_eq!(timings.n_p_eval(), 5);
assert_eq!(timings.n_eval(), 6);Sourcepub fn print(ctx: &LlamaContext<'_>)
pub fn print(ctx: &LlamaContext<'_>)
print llama context performance data load time prompt eval time eval time total time
Sourcepub fn t_start_ms(&self) -> f64
pub fn t_start_ms(&self) -> f64
Get the start time in milliseconds.
Sourcepub fn t_p_eval_ms(&self) -> f64
pub fn t_p_eval_ms(&self) -> f64
Get the prompt evaluation time in milliseconds.
Sourcepub fn n_reused(&self) -> i32
pub fn n_reused(&self) -> i32
How many times llama.cpp reused a cached compute graph instead of rebuilding it.
Graph reuse is the fast path. A low count against a high
Self::n_eval means something is invalidating the graph every step —
a changing batch shape, or toggling a context flag mid-generation.
Sourcepub fn n_reallocs_same(&self) -> i32
pub fn n_reallocs_same(&self) -> i32
Graph reallocations where the graph size was unchanged.
These should be rare: the shape did not change, so the buffers should have been reusable. A climbing count points at allocator churn rather than at your batching.
Sourcepub fn n_reallocs_diff(&self) -> i32
pub fn n_reallocs_diff(&self) -> i32
Graph reallocations where the graph size changed.
Expected whenever the batch shape moves — a prefill of a different length, or switching between prompt and single-token decode.
Sourcepub fn set_t_start_ms(&mut self, t_start_ms: f64)
pub fn set_t_start_ms(&mut self, t_start_ms: f64)
Set the start time in milliseconds.
Sourcepub fn set_t_load_ms(&mut self, t_load_ms: f64)
pub fn set_t_load_ms(&mut self, t_load_ms: f64)
Set the load time in milliseconds.
Sourcepub fn set_t_p_eval_ms(&mut self, t_p_eval_ms: f64)
pub fn set_t_p_eval_ms(&mut self, t_p_eval_ms: f64)
Set the prompt evaluation time in milliseconds.
Sourcepub fn set_t_eval_ms(&mut self, t_eval_ms: f64)
pub fn set_t_eval_ms(&mut self, t_eval_ms: f64)
Set the evaluation time in milliseconds.
Sourcepub fn set_n_p_eval(&mut self, n_p_eval: i32)
pub fn set_n_p_eval(&mut self, n_p_eval: i32)
Set the number of prompt evaluations.
Sourcepub fn set_n_eval(&mut self, n_eval: i32)
pub fn set_n_eval(&mut self, n_eval: i32)
Set the number of evaluations.