Operations performance

Hi All!
I have several tests in web project
All of them beginning with creating body for request
For example

body, _ := json.Marshal(map[string]interface{}{
		"someA": "stringOne",
		"someB": map[0].value
		"someC": "stringThree",
	})

Each test has unique body
But i can create func wich return me unique body for request
Which operations would being lighter/cheaper in this case?

  1. Without changes - create body in each test case
  2. Using function

Thaks!

Do you mean unit tests? Is it so important to save some nanoseconds for a function call? So, inline would be faster than function call, but code maintainability is usually much more important, so put it in a function.

1 Like

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.