Skip to content

Commit 95b0bec

Browse files
inkelsimonswine
andauthored
Refactor *PartitionWriter.WriteProfileSymbols for DRY
Thank you @simonswine for the suggestion! Co-authored-by: Christian Simon <simon@swine.de>
1 parent e7472e0 commit 95b0bec

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/phlaredb/symdb/symdb_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,19 @@ func TestWritePartition(t *testing.T) {
231231
func BenchmarkPartitionWriter_WriteProfileSymbols(b *testing.B) {
232232
b.ReportAllocs()
233233

234+
p, err := pprof.OpenFile("testdata/profile.pb.gz")
235+
require.NoError(b, err)
236+
p.Normalize()
237+
cfg := DefaultConfig().WithDirectory(b.TempDir())
238+
239+
db := NewSymDB(cfg)
240+
234241
for i := 0; i < b.N; i++ {
235-
// If opening the profile or creating the config, db, or
236-
// partition writer outside the loop it always results in a
237-
// panic.
238242
b.StopTimer()
239-
p, err := pprof.OpenFile("testdata/profile.pb.gz")
240-
require.NoError(b, err)
241-
p.Normalize()
242-
cfg := DefaultConfig().WithDirectory(b.TempDir())
243-
db := NewSymDB(cfg)
244-
pw := db.PartitionWriter(0)
243+
newP := p.CloneVT()
244+
pw := db.PartitionWriter(uint64(i))
245245
b.StartTimer()
246246

247-
pw.WriteProfileSymbols(p.Profile)
247+
pw.WriteProfileSymbols(newP)
248248
}
249249
}

0 commit comments

Comments
 (0)