-
Notifications
You must be signed in to change notification settings - Fork 240
Display gas report table #3842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: share-contracts-data-store
Are you sure you want to change the base?
Display gas report table #3842
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
8a9f925 to
8f3b1f6
Compare
8517806 to
73d507a
Compare
| [..]Compiling[..] | ||
| [..]Finished[..] | ||
| Collected 1 test(s) from simple_package package | ||
| Running 0 test(s) from src/ | ||
| Running 1 test(s) from tests/ | ||
| [PASS] simple_package_integrationtest::contract::call_and_invoke (l1_gas: ~0, l1_data_gas: ~[..], l2_gas: ~[..]) | ||
| ╭------------------------+-------+-------+-------+---------+---------╮ | ||
| | HelloStarknet Contract | | | | | | | ||
| +====================================================================+ | ||
| | Function Name | Min | Max | Avg | Std Dev | # Calls | | ||
| |------------------------+-------+-------+-------+---------+---------| | ||
| | get_balance | 13340 | 13340 | 13340 | 0 | 2 | | ||
| |------------------------+-------+-------+-------+---------+---------| | ||
| | increase_balance | 24940 | 24940 | 24940 | 0 | 1 | | ||
| ╰------------------------+-------+-------+-------+---------+---------╯ | ||
| Tests: 1 passed, 0 failed, 0 ignored, [..] filtered out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddoktorski wdyt about having the contract name centered and the heading cells being merged into one?
| if !contract_info.functions.is_empty() { | ||
| let table = format_table_output(contract_info, name); | ||
| writeln!(f, "\n{table}")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what case can there be contract without functions? In case it wasn't actually called in tests or some other ones as well?
| use comfy_table::modifiers::UTF8_ROUND_CORNERS; | ||
| use comfy_table::{Cell, Color, Table}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad someone already made a lib for that and we don't have to deal with printing tables
| Cell::new(report_data.gas_stats.min.to_string()).fg(Color::Green), | ||
| Cell::new(report_data.gas_stats.max.to_string()).fg(Color::Red), | ||
| Cell::new(report_data.gas_stats.mean.round().to_string()).fg(Color::Yellow), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this coloring. I'd rather eventually have some colors based on values or something. Maybe let's just have them all single color or even just white?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case when no functions are invoked, we don't display the table. Maybe we should inform a user by displaying info/warning message?
| let gas_report = if output_config.gas_report { | ||
| format!("{}", gas_info.report_data) | ||
| } else { | ||
| String::new() | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let gas_report = if output_config.gas_report { | |
| format!("{}", gas_info.report_data) | |
| } else { | |
| String::new() | |
| }; | |
| let gas_report = output_config | |
| .gas_report | |
| .then(|| gas_info.report_data.to_string()) | |
| .unwrap_or_default(); |
| table.add_row(vec![ | ||
| Cell::new("Function Name"), | ||
| Cell::new("Min").fg(Color::Green), | ||
| Cell::new("Max").fg(Color::Red), | ||
| Cell::new("Avg").fg(Color::Yellow), | ||
| Cell::new("Std Dev").fg(Color::Yellow), | ||
| Cell::new("# Calls").fg(Color::Cyan), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's make these header cells bold, with add_attribute(Attribute::Bold)
1c1e984 to
b5ef498
Compare
73d507a to
7c7f179
Compare
Towards #3660