Skip to content

Conversation

@ddoktorski
Copy link
Contributor

Towards #3660

@ddoktorski ddoktorski requested a review from a team as a code owner October 21, 2025 11:52
@ddoktorski ddoktorski requested review from MKowalski8 and franciszekjob and removed request for a team October 21, 2025 11:52
@ddoktorski ddoktorski marked this pull request as draft October 21, 2025 11:52
@ddoktorski ddoktorski force-pushed the add-gas-report-logic branch 2 times, most recently from 8a9f925 to 8f3b1f6 Compare October 22, 2025 18:37
@ddoktorski ddoktorski changed the base branch from add-gas-report-logic to share-contracts-data-store October 22, 2025 18:58
@ddoktorski ddoktorski force-pushed the 3660-gas-report branch 2 times, most recently from 8517806 to 73d507a Compare October 23, 2025 12:32
Comment on lines +17 to +35
[..]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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

Copy link
Contributor

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}")?;
Copy link
Member

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?

Comment on lines +3 to +4
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::{Cell, Color, Table};
Copy link
Member

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),
Copy link
Member

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?

Copy link
Contributor

@franciszekjob franciszekjob left a 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?

Comment on lines +81 to +85
let gas_report = if output_config.gas_report {
format!("{}", gas_info.report_data)
} else {
String::new()
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();

Comment on lines +144 to +149
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),
]);
Copy link
Contributor

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)

@ddoktorski ddoktorski force-pushed the share-contracts-data-store branch from 1c1e984 to b5ef498 Compare October 24, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants