-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR #1332: benchmarks: Add benchmark for block time to bank module
* benchmarks: Add benchmark folder, and single benchmark for block time * Move benchmark into module * Fix merge conflict errors * Fix spelling * Add instructions to run benchmark * Update auth_app_test.go
- Loading branch information
1 parent
b730ba6
commit 05608d4
Showing
6 changed files
with
136 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package bank | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/cosmos/cosmos-sdk/x/auth/mock" | ||
|
||
abci "github.com/tendermint/abci/types" | ||
) | ||
|
||
func BenchmarkOneBankSendTxPerBlock(b *testing.B) { | ||
benchmarkApp, _ := getBenchmarkMockApp() | ||
|
||
// Add an account at genesis | ||
acc := &auth.BaseAccount{ | ||
Address: addr1, | ||
// Some value conceivably higher than the benchmarks would ever go | ||
Coins: sdk.Coins{sdk.NewCoin("foocoin", 100000000000)}, | ||
} | ||
accs := []auth.Account{acc} | ||
|
||
// Construct genesis state | ||
mock.SetGenesis(benchmarkApp, accs) | ||
// Precompute all txs | ||
txs := mock.GenSequenceOfTxs([]sdk.Msg{sendMsg1}, []int64{0}, []int64{int64(0)}, b.N, priv1) | ||
b.ResetTimer() | ||
// Run this with a profiler, so its easy to distinguish what time comes from | ||
// Committing, and what time comes from Check/Deliver Tx. | ||
for i := 0; i < b.N; i++ { | ||
benchmarkApp.BeginBlock(abci.RequestBeginBlock{}) | ||
x := benchmarkApp.Check(txs[i]) | ||
if !x.IsOK() { | ||
panic("something is broken in checking transaction") | ||
} | ||
benchmarkApp.Deliver(txs[i]) | ||
benchmarkApp.EndBlock(abci.RequestEndBlock{}) | ||
benchmarkApp.Commit() | ||
} | ||
} |