@@ -194,7 +194,7 @@ func BenchmarkRuntimeCallContractBasic(b *testing.B) {
194194
195195 b .ResetTimer ()
196196 for i := 0 ; i < b .N ; i ++ {
197- result , err := contract .Call ("get_value" )
197+ result , err := contract .CallWithSerializedParams ("get_value" , nil )
198198 require .NoError (err )
199199 require .Equal (uint64 (0 ), into [uint64 ](result ))
200200 }
@@ -212,9 +212,11 @@ func BenchmarkRuntimeSendValue(b *testing.B) {
212212 require .NoError (err )
213213 contract .Runtime .StateManager .(TestStateManager ).Balances [contract .Address ] = consts .MaxUint64
214214
215+ params := test .SerializeParams (actor )
216+
215217 b .ResetTimer ()
216218 for i := 0 ; i < b .N ; i ++ {
217- result , err := contract .Call ("send_balance" , actor )
219+ result , err := contract .CallWithSerializedParams ("send_balance" , params )
218220 require .NoError (err )
219221 require .True (into [bool ](result ))
220222 }
@@ -235,14 +237,42 @@ func BenchmarkRuntimeBasicExternalCalls(b *testing.B) {
235237 require .NoError (err )
236238 addressOf := codec .CreateAddress (0 , ids .GenerateTestID ())
237239
240+ params := test .SerializeParams (counterAddress , addressOf )
241+
238242 b .ResetTimer ()
239243 for i := 0 ; i < b .N ; i ++ {
240- result , err := contract .Call ("get_value" , counterAddress , addressOf )
244+ result , err := contract .CallWithSerializedParams ("get_value" , params )
241245 require .NoError (err )
242246 require .Equal (uint64 (0 ), into [uint64 ](result ))
243247 }
244248}
245249
250+ // Benchmark an NFT
251+ func BenchmarkNFTMint (b * testing.B ) {
252+ require := require .New (b )
253+ ctx := context .Background ()
254+
255+ rt := newTestRuntime (ctx )
256+ nft , err := rt .newTestContract ("nft" )
257+ require .NoError (err )
258+
259+ _ , err = nft .Call ("init" , "NFT" , "NFT" )
260+ require .NoError (err )
261+
262+ actor := codec .CreateAddress (0 , ids .GenerateTestID ())
263+ params := make ([][]byte , b .N )
264+
265+ for i := 0 ; i < b .N ; i ++ {
266+ params [i ] = test .SerializeParams (actor , i )
267+ }
268+
269+ b .ResetTimer ()
270+ for i := 0 ; i < b .N ; i ++ {
271+ _ , err = nft .CallWithSerializedParams ("mint" , params [i ])
272+ require .NoError (err )
273+ }
274+ }
275+
246276// Benchmarks a contract that performs an AMM swap
247277func BenchmarkAmmSwaps (b * testing.B ) {
248278 require := require .New (b )
@@ -291,9 +321,11 @@ func BenchmarkAmmSwaps(b *testing.B) {
291321 _ , err = amm .WithActor (lp ).Call ("add_liquidity" , amountMint , amountMint )
292322 require .NoError (err )
293323
324+ params := test .SerializeParams (tokenX .Address , 150 )
325+
294326 b .ResetTimer ()
295327 for i := 0 ; i < b .N ; i ++ {
296- received , err := amm .WithActor (swaper ).Call ("swap" , tokenX . Address , 150 )
328+ received , err := amm .WithActor (swaper ).CallWithSerializedParams ("swap" , params )
297329 require .NoError (err )
298330 require .NotZero (received )
299331 }
0 commit comments