-
Notifications
You must be signed in to change notification settings - Fork 0
/
alaw_test.go
56 lines (49 loc) · 1.21 KB
/
alaw_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Copyright (C) 2016 - 2024, Lefteris Zafiris <zaf@fastmail.com>
This program is free software, distributed under the terms of
the BSD 3-Clause License. See the LICENSE file
at the top of the source tree.
Package g711 implements encoding and decoding of G711 PCM sound data.
G.711 is an ITU-T standard for audio companding.
*/
package g711
import (
"os"
"testing"
)
// Benchmark EncodeAlaw
func BenchmarkEncodeAlaw(b *testing.B) {
rawData, err := os.ReadFile("testing/speech.raw")
if err != nil {
b.Fatalf("Failed to read test data: %s\n", err)
}
b.SetBytes(int64(len(rawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
EncodeAlaw(rawData)
}
}
// Benchmark DecodeAlaw
func BenchmarkDecodeAlaw(b *testing.B) {
aData, err := os.ReadFile("testing/speech.alaw")
if err != nil {
b.Fatalf("Failed to read test data: %s\n", err)
}
b.SetBytes(int64(len(aData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
DecodeAlaw(aData)
}
}
// Benchmark Alaw2Ulaw
func BenchmarkAlaw2Ulaw(b *testing.B) {
aData, err := os.ReadFile("testing/speech.alaw")
if err != nil {
b.Fatalf("Failed to read test data: %s\n", err)
}
b.SetBytes(int64(len(aData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Alaw2Ulaw(aData)
}
}