Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add benchmark for ValidateOrder (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
albrow authored Jun 10, 2020
1 parent 5a57dea commit 4a026b9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions orderfilter/filter_bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package orderfilter

import (
"math/big"
"testing"

"github.com/0xProject/0x-mesh/constants"
"github.com/0xProject/0x-mesh/zeroex"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/stretchr/testify/require"
)

func BenchmarkValidateOrder(b *testing.B) {
order := &zeroex.Order{
ChainID: big.NewInt(constants.TestChainID),
MakerAddress: common.HexToAddress("0x5409ed021d9299bf6814279a6a1411a7e866a631"),
MakerAssetData: common.FromHex("0xf47261b0000000000000000000000000871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"),
MakerAssetAmount: math.MustParseBig256("1000"),
MakerFee: math.MustParseBig256("0"),
TakerAddress: common.HexToAddress("0x0000000000000000000000000000000000000000"),
TakerAssetData: common.FromHex("0xf47261b00000000000000000000000000b1ba0af832d7c05fd64161e0db78e85978e8082"),
TakerAssetAmount: math.MustParseBig256("2000"),
TakerFee: math.MustParseBig256("0"),
SenderAddress: common.HexToAddress("0x0000000000000000000000000000000000000000"),
ExchangeAddress: common.HexToAddress("0x48bacb9266a570d521063ef5dd96e61686dbe788"),
FeeRecipientAddress: common.HexToAddress("0xa258b39954cef5cb142fd567a46cddb31a670124"),
ExpirationTimeSeconds: math.MustParseBig256("1574532801"),
Salt: math.MustParseBig256("1548619145450"),
}

filter, err := New(constants.TestChainID, DefaultCustomOrderSchema, contractAddresses)
require.NoError(b, err)
signedOrder, err := zeroex.SignTestOrder(order)
require.NoError(b, err)
b.ResetTimer()

for i := 0; i < b.N; i++ {
_, err = filter.ValidateOrder(signedOrder)
b.StopTimer()
require.NoError(b, err)
b.StartTimer()
}
}

0 comments on commit 4a026b9

Please sign in to comment.