Skip to content

Commit

Permalink
make budget pretty again
Browse files Browse the repository at this point in the history
remove println
  • Loading branch information
jayz22 committed Apr 3, 2024
1 parent f21f026 commit 225c6b5
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 167 deletions.
22 changes: 11 additions & 11 deletions soroban-env-host/src/budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ impl Default for BudgetImpl {

impl Debug for BudgetImpl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:=<165}", "")?;
writeln!(f, "{:=<175}", "")?;
writeln!(
f,
"Cpu limit: {}; used: {}",
Expand All @@ -788,10 +788,10 @@ impl Debug for BudgetImpl {
"Mem limit: {}; used: {}",
self.mem_bytes.limit, self.mem_bytes.total_count
)?;
writeln!(f, "{:=<165}", "")?;
writeln!(f, "{:=<175}", "")?;
writeln!(
f,
"{:<25}{:<15}{:<15}{:<15}{:<15}{:<20}{:<20}{:<20}{:<20}",
"{:<35}{:<15}{:<15}{:<15}{:<15}{:<20}{:<20}{:<20}{:<20}",
"CostType",
"iterations",
"input",
Expand All @@ -806,7 +806,7 @@ impl Debug for BudgetImpl {
let i = ct as usize;
writeln!(
f,
"{:<25}{:<15}{:<15}{:<15}{:<15}{:<20}{:<20}{:<20}{:<20}",
"{:<35}{:<15}{:<15}{:<15}{:<15}{:<20}{:<20}{:<20}{:<20}",
format!("{:?}", ct),
self.tracker.cost_tracker[i].iterations,
format!("{:?}", self.tracker.cost_tracker[i].inputs),
Expand All @@ -818,7 +818,7 @@ impl Debug for BudgetImpl {
format!("{}", self.mem_bytes.cost_models[i].lin_term),
)?;
}
writeln!(f, "{:=<165}", "")?;
writeln!(f, "{:=<175}", "")?;
writeln!(
f,
"Internal details (diagnostics info, does not affect fees) "
Expand All @@ -838,14 +838,14 @@ impl Debug for BudgetImpl {
"Shadow mem limit: {}; used: {}",
self.mem_bytes.shadow_limit, self.mem_bytes.shadow_total_count
)?;
writeln!(f, "{:=<165}", "")?;
writeln!(f, "{:=<175}", "")?;
Ok(())
}
}

impl Display for BudgetImpl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:=<55}", "")?;
writeln!(f, "{:=<65}", "")?;
writeln!(
f,
"Cpu limit: {}; used: {}",
Expand All @@ -856,23 +856,23 @@ impl Display for BudgetImpl {
"Mem limit: {}; used: {}",
self.mem_bytes.limit, self.mem_bytes.total_count
)?;
writeln!(f, "{:=<55}", "")?;
writeln!(f, "{:=<65}", "")?;
writeln!(
f,
"{:<25}{:<15}{:<15}",
"{:<35}{:<15}{:<15}",
"CostType", "cpu_insns", "mem_bytes",
)?;
for ct in ContractCostType::variants() {
let i = ct as usize;
writeln!(
f,
"{:<25}{:<15}{:<15}",
"{:<35}{:<15}{:<15}",
format!("{:?}", ct),
self.tracker.cost_tracker[i].cpu,
self.tracker.cost_tracker[i].mem,
)?;
}
writeln!(f, "{:=<55}", "")?;
writeln!(f, "{:=<65}", "")?;
Ok(())
}
}
Expand Down
Loading

0 comments on commit 225c6b5

Please sign in to comment.