Reset timer in benchmark test functions

This commit is contained in:
bcmmbaga
2024-06-27 17:14:22 +03:00
parent b4dddc8d0f
commit 16387a823a

View File

@@ -142,6 +142,7 @@ func initTestAccount(b *testing.B, numPerAccount int) *Account {
// 500 - 1732888875 ns/op
func BenchmarkTest_updateAccountPeers100(b *testing.B) {
account := initTestAccount(b, 100)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -151,6 +152,7 @@ func BenchmarkTest_updateAccountPeers100(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash100(b *testing.B) {
account := initTestAccount(b, 100)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)
@@ -161,6 +163,7 @@ func BenchmarkTest_updateAccountPeersWithHash100(b *testing.B) {
// 500 - 1732888875 ns/op
func BenchmarkTest_updateAccountPeers200(b *testing.B) {
account := initTestAccount(b, 200)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -170,6 +173,7 @@ func BenchmarkTest_updateAccountPeers200(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash200(b *testing.B) {
account := initTestAccount(b, 200)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)
@@ -178,6 +182,7 @@ func BenchmarkTest_updateAccountPeersWithHash200(b *testing.B) {
func BenchmarkTest_updateAccountPeers500(b *testing.B) {
account := initTestAccount(b, 500)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -187,6 +192,7 @@ func BenchmarkTest_updateAccountPeers500(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash500(b *testing.B) {
account := initTestAccount(b, 500)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)
@@ -195,6 +201,7 @@ func BenchmarkTest_updateAccountPeersWithHash500(b *testing.B) {
func BenchmarkTest_updateAccountPeers1000(b *testing.B) {
account := initTestAccount(b, 1000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -204,6 +211,7 @@ func BenchmarkTest_updateAccountPeers1000(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash1000(b *testing.B) {
account := initTestAccount(b, 1000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)
@@ -212,6 +220,7 @@ func BenchmarkTest_updateAccountPeersWithHash1000(b *testing.B) {
func BenchmarkTest_updateAccountPeers1500(b *testing.B) {
account := initTestAccount(b, 1500)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -221,6 +230,7 @@ func BenchmarkTest_updateAccountPeers1500(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash1500(b *testing.B) {
account := initTestAccount(b, 1500)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)
@@ -229,6 +239,7 @@ func BenchmarkTest_updateAccountPeersWithHash1500(b *testing.B) {
func BenchmarkTest_updateAccountPeers2000(b *testing.B) {
account := initTestAccount(b, 2000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
updateAccountPeers(account)
}
@@ -238,6 +249,7 @@ func BenchmarkTest_updateAccountPeers2000(b *testing.B) {
// 500 - 7365024500 ns/op
func BenchmarkTest_updateAccountPeersWithHash2000(b *testing.B) {
account := initTestAccount(b, 2000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
log.Debug(i)
updateAccountPeersWithHash(account)