-
Notifications
You must be signed in to change notification settings - Fork 47
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
Computation reports for Cadence scripts & transactions #609
Computation reports for Cadence scripts & transactions #609
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #609 +/- ##
==========================================
+ Coverage 50.80% 50.93% +0.13%
==========================================
Files 32 33 +1
Lines 4224 4421 +197
==========================================
+ Hits 2146 2252 +106
- Misses 1907 1996 +89
- Partials 171 173 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks good. Some comments:
- It might be good to link to this function as an example on how to get the computation from the intensities https://github.com/onflow/flow-go/blob/master/fvm/meter/computation_meter.go#L32
- The naming: "profiling" hints to the profiling where you can see results per line of code executed which is a bit misleading. However if I understand correctly you intend to work towards that. If that is the case I'm ok with the name.
emulator/computation_profile.go
Outdated
|
||
// transformIntensities maps a numeric common.ComputationKind value | ||
// to a human-friendly string value. | ||
func transformIntensities( |
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.
I wish flow-go already offered ComputationKind names.
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.
Unfortunately, I think this is not possible. The main problem is that ComputationKind
is defined in Cadence repository and it uses the string
cmd tool to generate the String
representation for the values defined there. See: https://github.com/onflow/cadence/blob/master/runtime/common/compositekind.go#L27
Only the ComputationKind
values defined in Cadence offer a human-readable name: https://github.com/onflow/cadence/blob/master/runtime/common/computationkind_string.go.
emulator/computation_profile_test.go
Outdated
expectedIntensities := map[string]uint{ | ||
"FunctionInvocation": 2, | ||
"GetAccountContractCode": 1, | ||
"GetCode": 1, | ||
"GetOrLoadProgram": 3, | ||
"GetValue": 221, | ||
"ResolveLocation": 1, | ||
"Statement": 1, | ||
} |
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.
I would not compare all the values, as the test might become fragile.
I would maybe omit GetValue
and perhaps GetOrLoadProgram
as well.
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.
Good point 👍
Updated in 5dc4699
emulator/computation_profile_test.go
Outdated
"AllocateStorageIndex": 2, | ||
"CreateCompositeValue": 2, | ||
"CreateDictionaryValue": 1, | ||
"EmitEvent": 73, | ||
"EncodeEvent": 1, | ||
"EncodeValue": 2336, | ||
"FunctionInvocation": 9, | ||
"GenerateAccountLocalID": 1, | ||
"GenerateUUID": 1, | ||
"GetAccountContractCode": 1, | ||
"GetCode": 1, | ||
"GetOrLoadProgram": 3, | ||
"GetValue": 2249, | ||
"ResolveLocation": 1, | ||
"SetValue": 2473, | ||
"Statement": 11, | ||
"TransferCompositeValue": 3, |
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.
I would not check:
- EncodeValue
- GetValue
- SetValue
- AllocateStorageIndex
- GetOrLoadProgram
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.
Good point 👍
Updated in 5dc4699
@janezpodhostnik I have updated the naming pattern to |
61361f0
to
a3c399f
Compare
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.
Very nice work, this is an awesome feature! 🎉
c21ffd9
to
f7eb861
Compare
…or its functionality
…pes and variables
f7eb861
to
963b2be
Compare
Completes: 1st milestone of onflow/developer-grants#178
Closes: #526
Description
Introduces a new endpoint under
http://localhost:8080/emulator/computationReport
, to display computation reports. For example:For contributor use:
master
branchFiles changed
in the GitHub PR explorer