github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/bench/microbenchmarks/apitests/actionmsg_test.go (about)

     1  // Package integration contains AIS integration tests.
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package apitests_test
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/NVIDIA/aistore/api/apc"
    11  	"github.com/NVIDIA/aistore/cmn/cos"
    12  	jsoniter "github.com/json-iterator/go"
    13  )
    14  
    15  func BenchmarkActionMsgMarshal(b *testing.B) {
    16  	for range b.N {
    17  		msg := apc.ActMsg{
    18  			Name:   "test-name",
    19  			Action: apc.ActDeleteObjects,
    20  			Value:  &apc.ListRange{Template: "thisisatemplate"},
    21  		}
    22  		data, err := jsoniter.Marshal(&msg)
    23  		if err != nil {
    24  			b.Errorf("marshaling errored: %v", err)
    25  		}
    26  		msg2 := &apc.ActMsg{}
    27  		err = jsoniter.Unmarshal(data, &msg2)
    28  		if err != nil {
    29  			b.Errorf("unmarshaling errored: %v", err)
    30  		}
    31  		err = cos.MorphMarshal(msg2.Value, &apc.ListRange{})
    32  		if err != nil {
    33  			b.Errorf("morph unmarshal errored: %v", err)
    34  		}
    35  	}
    36  }