commit 8e6998c8994381afcacf51d9a0fe6c6f8b101597
parent 666898492c80aabd1195ba8856066b0858b57189
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date: Tue, 26 Oct 2021 16:46:01 +0800
nativeaudio: benchmark native decode against ffmpeg
Benchmark native load against ffmepg load. Unfortunately we have to go
through the filesystem because of deficiencies in FFmpegDecode (some
audio formats cannot be piped to ffmpeg).
goos: windows
goarch: amd64
pkg: git.sr.ht/~jackmordaunt/nativeaudio/internal/test
cpu: AMD Ryzen 5 3600 6-Core Processor
BenchmarkDecode/native-12 4 318420150 ns/op 606240 B/op 3 allocs/op
BenchmarkDecode/ffmpeg-12 19 61705947 ns/op 2279976 B/op 1498 allocs/op
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/internal/test/audio_test.go b/internal/test/audio_test.go
@@ -122,3 +122,26 @@ func abs(n int) int {
}
return n
}
+
+func BenchmarkDecode(b *testing.B) {
+ b.Run("native", func(b *testing.B) {
+ for ii := 0; ii < b.N; ii++ {
+ by, f, err := nativeaudio.Load("compressed.m4a")
+ if err != nil {
+ b.Fatalf("unexpected error during decode: %v", err)
+ }
+ _ = by
+ _ = f
+ }
+ })
+ b.Run("ffmpeg", func(b *testing.B) {
+ for ii := 0; ii < b.N; ii++ {
+ by, f, err := nativeaudio.FFmpegLoad("compressed.m4a")
+ if err != nil {
+ b.Fatalf("unexpected error during decode: %v", err)
+ }
+ _ = by
+ _ = f
+ }
+ })
+}