func getBaseData(b fatalF) []byte { cust := base.NewCustomer() buf, err := json.MarshalIndent(&cust, "", " ") if err != nil { b.Fatalf("Marshal: %v", err) } return buf }
func BenchmarkMarshalJSON(b *testing.B) { cust := base.NewCustomer() buf, err := json.Marshal(&cust) if err != nil { b.Fatalf("Marshal: %v", err) } b.SetBytes(int64(len(buf))) b.ResetTimer() for i := 0; i < b.N; i++ { _, err := json.Marshal(&cust) if err != nil { b.Fatalf("Marshal: %v", err) } } }