Skip to content

Commit

Permalink
fix(tm2): enable coin benchmark tests after fixing panic error (#2884)
Browse files Browse the repository at this point in the history
Relate to #907

Make a few small fixes to get this test working
<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] 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](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
  • Loading branch information
sunspirit99 authored Oct 23, 2024
1 parent 43dd3f3 commit e34a8f7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tm2/pkg/std/coin_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ package std

import (
"fmt"
"strconv"
"testing"
)

func BenchmarkCoinsAdditionIntersect(b *testing.B) {
b.Skip("TODO: panicking benchmark")
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
return func(b *testing.B) {
b.Helper()

coinsA := Coins(make([]Coin, numCoinsA))
coinsB := Coins(make([]Coin, numCoinsB))

maxCoins := max(numCoinsA, numCoinsB)
denomLength := len(fmt.Sprint(maxCoins))

for i := 0; i < numCoinsA; i++ {
coinsA[i] = NewCoin("COINZ_"+strconv.Itoa(i), (int64(i)))
denom := fmt.Sprintf("coinz_%0*d", denomLength, i)
coinsA[i] = NewCoin(denom, int64(i+1))
}
for i := 0; i < numCoinsB; i++ {
coinsB[i] = NewCoin("COINZ_"+strconv.Itoa(i), (int64(i)))
denom := fmt.Sprintf("coinz_%0*d", denomLength, i)
coinsB[i] = NewCoin(denom, int64(i+1))
}

b.ResetTimer()
Expand All @@ -39,19 +42,23 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
}

func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
b.Skip("TODO: panicking benchmark")
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
return func(b *testing.B) {
b.Helper()

coinsA := Coins(make([]Coin, numCoinsA))
coinsB := Coins(make([]Coin, numCoinsB))

maxCoins := max(numCoinsA, numCoinsB)
denomLength := len(fmt.Sprint(maxCoins))

for i := 0; i < numCoinsA; i++ {
coinsA[i] = NewCoin("COINZ_"+strconv.Itoa(numCoinsB+i), (int64(i)))
denom := fmt.Sprintf("coinz_%0*d", denomLength, i)
coinsA[i] = NewCoin(denom, int64(i+1))
}
for i := 0; i < numCoinsB; i++ {
coinsB[i] = NewCoin("COINZ_"+strconv.Itoa(i), (int64(i)))
denom := fmt.Sprintf("coinz_%0*d", denomLength, i)
coinsB[i] = NewCoin(denom, int64(i+1))
}

b.ResetTimer()
Expand Down

1 comment on commit e34a8f7

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Go Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: e34a8f7 Previous: 43dd3f3 Ratio
BenchmarkBinary/EmptyStruct:encode 473.2 ns/op 96 B/op 2 allocs/op 290.6 ns/op 96 B/op 2 allocs/op 1.63
BenchmarkBinary/EmptyStruct:encode - ns/op 473.2 ns/op 290.6 ns/op 1.63
BenchmarkBinary/EmptyStruct:decode 246 ns/op 0 B/op 0 allocs/op 134.2 ns/op 0 B/op 0 allocs/op 1.83
BenchmarkBinary/EmptyStruct:decode - ns/op 246 ns/op 134.2 ns/op 1.83
BenchmarkBinary/ShortArraysStruct:decode 406.2 ns/op 0 B/op 0 allocs/op 213.6 ns/op 0 B/op 0 allocs/op 1.90
BenchmarkBinary/ShortArraysStruct:decode - ns/op 406.2 ns/op 213.6 ns/op 1.90
BenchmarkRemoved 36.8 ns/op 0 B/op 0 allocs/op 29.17 ns/op 0 B/op 0 allocs/op 1.26
BenchmarkRemoved - ns/op 36.8 ns/op 29.17 ns/op 1.26
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 63674563 ns/op 5130 B/op 9 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 63674563 ns/op 31841703 ns/op 2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 127267110 ns/op 5139 B/op 9 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 4.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 127267110 ns/op 31841703 ns/op 4.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 254450810 ns/op 5158 B/op 9 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 7.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 254450810 ns/op 31841703 ns/op 7.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 508915544 ns/op 5196 B/op 10 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 15.98
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 508915544 ns/op 31841703 ns/op 15.98
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 1017562746 ns/op 5528 B/op 13 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 31.96
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 1017562746 ns/op 31841703 ns/op 31.96
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op 13 allocs/op 9 allocs/op 1.44
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 2034617035 ns/op 5736 B/op 15 allocs/op 31841703 ns/op 5125 B/op 9 allocs/op 63.90
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 2034617035 ns/op 31841703 ns/op 63.90
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op 15 allocs/op 9 allocs/op 1.67
BenchmarkSigning 83564 ns/op 1856 B/op 36 allocs/op 25722 ns/op 64 B/op 1 allocs/op 3.25
BenchmarkSigning - ns/op 83564 ns/op 25722 ns/op 3.25
BenchmarkSigning - B/op 1856 B/op 64 B/op 29
BenchmarkSigning - allocs/op 36 allocs/op 1 allocs/op 36
BenchmarkSigning 84420 ns/op 1856 B/op 36 allocs/op 25722 ns/op 64 B/op 1 allocs/op 3.28
BenchmarkSigning - ns/op 84420 ns/op 25722 ns/op 3.28
BenchmarkSigning - B/op 1856 B/op 64 B/op 29
BenchmarkSigning - allocs/op 36 allocs/op 1 allocs/op 36
BenchmarkVerification 170051 ns/op 864 B/op 19 allocs/op 61371 ns/op 0 B/op 0 allocs/op 2.77
BenchmarkVerification - ns/op 170051 ns/op 61371 ns/op 2.77
BenchmarkVerification - B/op 864 B/op 0 B/op +∞
BenchmarkVerification - allocs/op 19 allocs/op 0 allocs/op +∞
BenchmarkVerification 160924 ns/op 864 B/op 19 allocs/op 61371 ns/op 0 B/op 0 allocs/op 2.62
BenchmarkVerification - ns/op 160924 ns/op 61371 ns/op 2.62
BenchmarkVerification - B/op 864 B/op 0 B/op +∞
BenchmarkVerification - allocs/op 19 allocs/op 0 allocs/op +∞
BenchmarkRandomBytes/random 69.25 ns/op 16 B/op 1 allocs/op 33.02 ns/op 4 B/op 1 allocs/op 2.10
BenchmarkRandomBytes/random - ns/op 69.25 ns/op 33.02 ns/op 2.10
BenchmarkRandomBytes/random - B/op 16 B/op 4 B/op 4
BenchmarkRandomBytes/random 104.9 ns/op 32 B/op 1 allocs/op 33.02 ns/op 4 B/op 1 allocs/op 3.18
BenchmarkRandomBytes/random - ns/op 104.9 ns/op 33.02 ns/op 3.18
BenchmarkRandomBytes/random - B/op 32 B/op 4 B/op 8
BenchmarkRandomBytes/random 269 ns/op 112 B/op 1 allocs/op 33.02 ns/op 4 B/op 1 allocs/op 8.15
BenchmarkRandomBytes/random - ns/op 269 ns/op 33.02 ns/op 8.15
BenchmarkRandomBytes/random - B/op 112 B/op 4 B/op 28
BenchmarkRandomBytes/random 2359 ns/op 1024 B/op 1 allocs/op 33.02 ns/op 4 B/op 1 allocs/op 71.44
BenchmarkRandomBytes/random - ns/op 2359 ns/op 33.02 ns/op 71.44
BenchmarkRandomBytes/random - B/op 1024 B/op 4 B/op 256
BenchmarkSmall/boltdb-1000-100-16-40/update 1533897 ns/op 48423 B/op 413 allocs/op 998645 ns/op 37727 B/op 372 allocs/op 1.54
BenchmarkSmall/boltdb-1000-100-16-40/update - ns/op 1533897 ns/op 998645 ns/op 1.54
BenchmarkSmall/boltdb-1000-100-16-40/update - B/op 48423 B/op 37727 B/op 1.28
BenchmarkSmall/memdb-1000-100-16-40/block 18202450 ns/op 9185127 B/op 167448 allocs/op 13079643 ns/op 6605123 B/op 117150 allocs/op 1.39
BenchmarkSmall/memdb-1000-100-16-40/block - ns/op 18202450 ns/op 13079643 ns/op 1.39
BenchmarkSmall/memdb-1000-100-16-40/block - B/op 9185127 B/op 6605123 B/op 1.39
BenchmarkSmall/memdb-1000-100-16-40/block - allocs/op 167448 allocs/op 117150 allocs/op 1.43
BenchmarkMedium/boltdb-100000-100-16-40/update 6837950 ns/op 129749 B/op 1007 allocs/op 4970221 ns/op 97109 B/op 821 allocs/op 1.38
BenchmarkMedium/boltdb-100000-100-16-40/update - ns/op 6837950 ns/op 4970221 ns/op 1.38
BenchmarkMedium/boltdb-100000-100-16-40/update - B/op 129749 B/op 97109 B/op 1.34
BenchmarkMedium/boltdb-100000-100-16-40/update - allocs/op 1007 allocs/op 821 allocs/op 1.23
BenchmarkMedium/memdb-100000-100-16-40/update - B/op 375492 B/op 258705 B/op 1.45
BenchmarkMedium/memdb-100000-100-16-40/update - allocs/op 7438 allocs/op 4990 allocs/op 1.49
BenchmarkLevelDBBatchSizes/goleveldb-100000-25-16-40/block 10529144 ns/op 1583864 B/op 17636 allocs/op 8475554 ns/op 1398219 B/op 17108 allocs/op 1.24
BenchmarkLevelDBBatchSizes/goleveldb-100000-25-16-40/block - ns/op 10529144 ns/op 8475554 ns/op 1.24
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - B/op 49643 B/op 38762 B/op 1.28
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - allocs/op 591 allocs/op 448 allocs/op 1.32
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/update - allocs/op 430 allocs/op 340 allocs/op 1.26
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block 645382348 ns/op 94972512 B/op 1169686 allocs/op 531906609 ns/op 78974738 B/op 989651 allocs/op 1.21
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - ns/op 645382348 ns/op 531906609 ns/op 1.21
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - B/op 94972512 B/op 78974738 B/op 1.20
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - B/op 111312208 B/op 78974738 B/op 1.41
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - allocs/op 1262277 allocs/op 989651 allocs/op 1.28
BenchmarkHash/ripemd160 2833 ns/op 25 B/op 1 allocs/op 703.1 ns/op 25 B/op 1 allocs/op 4.03
BenchmarkHash/ripemd160 - ns/op 2833 ns/op 703.1 ns/op 4.03
BenchmarkHash/sha2-256 519.4 ns/op 33 B/op 1 allocs/op 170.9 ns/op 33 B/op 1 allocs/op 3.04
BenchmarkHash/sha2-256 - ns/op 519.4 ns/op 170.9 ns/op 3.04
BenchmarkHash/sha3-256 1840 ns/op 33 B/op 1 allocs/op 718.3 ns/op 33 B/op 1 allocs/op 2.56
BenchmarkHash/sha3-256 - ns/op 1840 ns/op 718.3 ns/op 2.56
BenchmarkWriteSecretConnection 6291 ns/op 0 B/op 0 allocs/op 4127 ns/op 0 B/op 0 allocs/op 1.52
BenchmarkWriteSecretConnection - ns/op 6291 ns/op 4127 ns/op 1.52
BenchmarkReadSecretConnection 3555 ns/op 0 B/op 0 allocs/op 2352 ns/op 0 B/op 0 allocs/op 1.51
BenchmarkReadSecretConnection - ns/op 3555 ns/op 2352 ns/op 1.51

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ajnavarro @thehowl @zivkovicmilos

Please sign in to comment.