(gdb: &GlobalDb, range: &str, summary: &CostSummary)
| 139 | } |
| 140 | |
| 141 | async fn print_default_summary(gdb: &GlobalDb, range: &str, summary: &CostSummary) { |
| 142 | let today_since = tracedecay::accounting::metrics::parse_range("today"); |
| 143 | let today_cost = gdb.total_cost_since(today_since).await.unwrap_or(0.0); |
| 144 | let today_breakdown = gdb |
| 145 | .token_breakdown_since(today_since) |
| 146 | .await |
| 147 | .unwrap_or((0, 0, 0)); |
| 148 | |
| 149 | println!( |
| 150 | " {:<10} {:>10} {:>10} {:>10} {:>10}", |
| 151 | "Period", "Cost", "Input", "Output", "Cache-hit" |
| 152 | ); |
| 153 | print_cost_row( |
| 154 | "Today", |
| 155 | today_cost, |
| 156 | today_breakdown.0, |
| 157 | today_breakdown.1, |
| 158 | today_breakdown.2, |
| 159 | ); |
| 160 | print_cost_row( |
| 161 | range, |
| 162 | summary.total_cost, |
| 163 | summary.total_input_tokens, |
| 164 | summary.total_output_tokens, |
| 165 | summary.total_cache_read_tokens, |
| 166 | ); |
| 167 | |
| 168 | if summary.tokens_saved > 0 { |
| 169 | let saved = tracedecay::display::format_token_count(summary.tokens_saved); |
| 170 | println!(); |
| 171 | println!( |
| 172 | " Savings {} tokens ({:.0}% efficiency)", |
| 173 | saved, |
| 174 | summary.efficiency_ratio * 100.0 |
| 175 | ); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | fn print_cost_row(label: &str, cost: f64, input: u64, output: u64, cache_read: u64) { |
| 180 | let cache_pct = if input + cache_read > 0 { |
no test coverage detected