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

Add array slice function #1315

Merged
merged 9 commits into from
Jan 7, 2022
Merged

Add array slice function #1315

merged 9 commits into from
Jan 7, 2022

Conversation

turbolent
Copy link
Member

Closes #1314

Description

  • Add a function fun slice(from: Int, upTo: Int): [T] to non-resource-kinded arrays (variable and constant-sized), similar to how it exists for strings
  • Depends on latest atree feature, array range iterators

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@github-actions
Copy link

github-actions bot commented Dec 16, 2021

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 51cac40
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
QualifiedIdentifierCreation/One_level-22.77ns ± 2%3.14ns ± 2%+13.26%(p=0.001 n=7+7)
NewInterpreter/new_sub-interpreter-22.31µs ± 2%2.36µs ± 2%+2.35%(p=0.035 n=7+6)
RuntimeFungibleTokenTransfer-21.44ms ±18%1.42ms ±22%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-216.5ms ± 4%16.3ms ± 3%~(p=0.456 n=7+7)
ParseDeploy/decode_hex-21.40ms ± 3%1.38ms ± 3%~(p=0.318 n=7+7)
QualifiedIdentifierCreation/Three_levels-2164ns ± 3%162ns ± 3%~(p=0.259 n=7+7)
ContractInterfaceFungibleToken-246.2µs ± 2%46.7µs ± 2%~(p=0.259 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2154µs ± 2%156µs ± 8%~(p=0.628 n=6+7)
NewInterpreter/new_interpreter-21.19µs ± 6%1.19µs ± 5%~(p=0.902 n=7+7)
InterpretRecursionFib-22.66ms ± 1%2.73ms ± 6%~(p=0.101 n=6+7)
ParseDeploy/byte_array-236.6ms ± 2%26.5ms ±13%−27.48%(p=0.001 n=7+7)
ParseArray-224.0ms ± 4%16.5ms ± 6%−31.27%(p=0.001 n=7+6)
ParseFungibleToken-2473µs ± 3%212µs ± 4%−55.19%(p=0.001 n=7+7)
ParseInfix-225.4µs ± 2%11.2µs ± 3%−55.95%(p=0.001 n=6+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2238kB ± 0%273kB ± 0%+14.61%(p=0.001 n=7+7)
RuntimeResourceDictionaryValues-24.04MB ± 0%4.05MB ± 0%+0.42%(p=0.001 n=7+7)
ContractInterfaceFungibleToken-226.5kB ± 0%26.5kB ± 0%+0.02%(p=0.001 n=7+7)
CheckContractInterfaceFungibleTokenConformance-265.7kB ± 0%65.7kB ± 0%+0.02%(p=0.001 n=6+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
NewInterpreter/new_interpreter-2720B ± 0%720B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.18kB ± 0%1.18kB ± 0%~(all equal)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=0.192 n=7+7)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=0.510 n=7+7)
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.206 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2457 ± 0%457 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
NewInterpreter/new_interpreter-211.0 ± 0%11.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-236.0 ± 0%36.0 ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
 

@codecov-commenter
Copy link

Codecov Report

Merging #1315 (ce4487e) into master (51cac40) will increase coverage by 0.04%.
The diff coverage is 91.17%.

❗ Current head ce4487e differs from pull request most recent head e913758. Consider uploading reports for the commit e913758 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1315      +/-   ##
==========================================
+ Coverage   77.43%   77.47%   +0.04%     
==========================================
  Files         279      279              
  Lines       36174    36301     +127     
==========================================
+ Hits        28010    28125     +115     
- Misses       7071     7082      +11     
- Partials     1093     1094       +1     
Flag Coverage Δ
unittests 77.47% <91.17%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/errors.go 22.48% <0.00%> (-1.69%) ⬇️
runtime/sema/string_type.go 100.00% <ø> (ø)
runtime/interpreter/value.go 80.57% <96.90%> (+0.30%) ⬆️
runtime/sema/type.go 88.33% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51cac40...e913758. Read the comment docs.

@turbolent turbolent merged commit 7218aac into master Jan 7, 2022
@turbolent turbolent deleted the bastian/1314-array-slice branch January 7, 2022 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array slice function
4 participants