INNER CODE UNIT · Go
BenchmarkParseAttributes_Old
simagix/hatchet · benchmark_test.go:70
func BenchmarkParseAttributes_Old(b *testing.B) {
doc := Logv2Info{}
bson.UnmarshalExtJSON([]byte(benchmarkLogStr), false, &doc)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
// Old approach
data, _ := bson.Marshal(doc.Attr)
bson.Unmarshal(data, &doc.Attributes)
}
}
// BenchmarkAnalyzeSlowOp benchmarks slow operation analysis
func BenchmarkAnalyzeSlowOp(b *testing.B) {
doc := Logv2Info{}
bson.UnmarshalExtJSON([]byte(benchmarkLogStr), false, &doc)
AddLegacyString(&doc)