Skip to content

Commit

Permalink
add fmp4.Part.Marshal benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Apr 9, 2024
1 parent be13a10 commit cb5f90f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/formats/fmp4/parts_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fmp4

import (
"bytes"
"testing"

"github.com/bluenviron/mediacommon/pkg/formats/fmp4/seekablebuffer"
Expand Down Expand Up @@ -192,3 +193,24 @@ func BenchmarkPartsUnmarshal(b *testing.B) {
}
}
}

func BenchmarkPartsMarshal(b *testing.B) {
parts := Parts{{
Tracks: []*PartTrack{{
ID: 1,
Samples: make([]*PartSample, 10000),
}},
}}

for i := 0; i < 10000; i++ {
parts[0].Tracks[0].Samples[i] = &PartSample{
Duration: 90000,
Payload: bytes.Repeat([]byte{1}, 16),
}
}

for i := 0; i < b.N; i++ {
var buf seekablebuffer.Buffer
parts.Marshal(&buf) //nolint:errcheck
}
}

0 comments on commit cb5f90f

Please sign in to comment.