-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f297689
commit ebb01d8
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package operation_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/onflow/flow-go/model/flow" | ||
"github.com/onflow/flow-go/storage" | ||
"github.com/onflow/flow-go/storage/operation" | ||
"github.com/onflow/flow-go/storage/operation/dbtest" | ||
"github.com/onflow/flow-go/utils/unittest" | ||
) | ||
|
||
func BenchmarkRetrieveApprovals(b *testing.B) { | ||
dbtest.BenchWithDB(b, func(b *testing.B, db storage.DB) { | ||
b.Run("RetrieveApprovals", func(b *testing.B) { | ||
approval := unittest.ResultApprovalFixture() | ||
require.NoError(b, db.WithReaderBatchWriter(storage.OnlyWriter(operation.InsertResultApproval(approval)))) | ||
|
||
b.ResetTimer() | ||
|
||
approvalID := approval.ID() | ||
b.RunParallel(func(pb *testing.PB) { | ||
for pb.Next() { | ||
var stored flow.ResultApproval | ||
require.NoError(b, operation.RetrieveResultApproval(approvalID, &stored)(db.Reader())) | ||
} | ||
}) | ||
|
||
}) | ||
}) | ||
} | ||
|
||
func BenchmarkInsertApproval(b *testing.B) { | ||
dbtest.BenchWithDB(b, func(b *testing.B, db storage.DB) { | ||
b.Run("InsertApprovals", func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
approval := unittest.ResultApprovalFixture() | ||
require.NoError(b, db.WithReaderBatchWriter(storage.OnlyWriter(operation.InsertResultApproval(approval)))) | ||
} | ||
}) | ||
}) | ||
} |
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