Skip to content
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

feat(gnovm): gno test now has gas used information #2571

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

thinhnx-var
Copy link
Contributor

@thinhnx-var thinhnx-var commented Jul 10, 2024

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

Why do we have this PR?

After discussion in #2467 and #2149 that the gno test now has gas used information instead of execution time.

Target:

  • gno test has total gas used information
  • gno test has gas used for each xxx_filetest.gno

I will add realm storage diff size #2468 in another PR.

  • image
  • image

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jul 10, 2024
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 60.44%. Comparing base (dd2d374) to head (e90b0d8).

Files with missing lines Patch % Lines
gnovm/tests/file.go 72.72% 3 Missing ⚠️
gnovm/cmd/gno/test.go 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2571   +/-   ##
=======================================
  Coverage   60.44%   60.44%           
=======================================
  Files         563      563           
  Lines       75159    75172   +13     
=======================================
+ Hits        45431    45441   +10     
- Misses      26341    26344    +3     
  Partials     3387     3387           
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
gno.land 67.21% <ø> (ø)
gnovm 64.48% <84.00%> (+0.01%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (ø)
tm2 62.11% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@linhpn99
Copy link
Contributor

If the gas used for each test case is displayed, that would be great :)

@linhpn99
Copy link
Contributor

If the gas used for each test case is displayed, that would be great :)

And it would be even better if we displayed both the execution time and the gas used :)

Copy link
Contributor

@deelawn deelawn left a comment

Choose a reason for hiding this comment

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

Nice idea. Some style comments and also -- are also those lines supposed to commented out?

gnovm/cmd/gno/test.go Outdated Show resolved Hide resolved
gnovm/tests/file_test.go Outdated Show resolved Hide resolved
gnovm/tests/file.go Outdated Show resolved Hide resolved
gnovm/tests/file.go Show resolved Hide resolved
gnovm/tests/file.go Outdated Show resolved Hide resolved
@@ -205,7 +206,7 @@ func execTest(cfg *testCfg, args []string, io commands.IO) error {
io.ErrPrintfln("FAIL")
testErrCount++
} else {
io.ErrPrintfln("ok %s \t%s", pkg.Dir, dstr)
io.ErrPrintfln("ok %s \ttotal gas used: %d", pkg.Dir, gasUsed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we have both gas used and duration? Both seem useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that people are not often concern about that time so much.

Copy link
Contributor

@deelawn deelawn Jul 23, 2024

Choose a reason for hiding this comment

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

I'll ask in another way -- how do we benefit from removing it? If someone doesn't care about it then they don't have to use it. If someone does care about it then they have it. It's only a few more characters being printed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@deelawn
I am fine with keeping the duration to be displayed.
But I have another view, should we move duration to -print-runtime-metrics which currently displaying runtime: cycle=%s imports=%d allocs=%s?

Copy link
Contributor

Choose a reason for hiding this comment

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

Before these changes, only subpackage level test execution displayed duration. The runtime metrics are something different. I'm only suggesting that we don't remove existing functionality if there is no good reason to do so. I don't think duration needs to be added anywhere else it doesn't currently exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right 👍 . I re-added the executing duration back again.
The result now looks like this:
image

gnovm/cmd/gno/test.go Outdated Show resolved Hide resolved
gnovm/cmd/gno/test.go Outdated Show resolved Hide resolved
gnovm/stdlibs/testing/testing.gno Outdated Show resolved Hide resolved
@thinhnx-var
Copy link
Contributor Author

Thanks for reviewing with so much details.
About displaying gasUsed instead of duration, I think people seems to not concern about the duration so much. I am not sure about this :)
Do you have any idea about removing or keeping this duration ?
cc to @moul @deelawn

@thinhnx-var thinhnx-var force-pushed the dev-thinhnx/feat_gno_test_has_gasused branch from 5a85bec to 0cc91ce Compare August 11, 2024 03:46
@Kouteki Kouteki added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 3, 2024
@Kouteki Kouteki removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants