forked from zaf/g711
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ulaw_test.go
56 lines (49 loc) · 1.23 KB
/
ulaw_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 - 2017, Lefteris Zafiris <[email protected]>
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 (
"io/ioutil"
"testing"
)
// Benchmark EncodeUlaw
func BenchmarkEncodeUlaw(b *testing.B) {
rawData, err := ioutil.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++ {
EncodeUlaw(rawData)
}
}
// Benchmark DecodeUlaw
func BenchmarkDecodeUlaw(b *testing.B) {
uData, err := ioutil.ReadFile("testing/speech.ulaw")
if err != nil {
b.Fatalf("Failed to read test data: %s\n", err)
}
b.SetBytes(int64(len(uData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
DecodeUlaw(uData)
}
}
// Benchmark Ulaw2Alaw
func BenchmarkUlaw2Alaw(b *testing.B) {
uData, err := ioutil.ReadFile("testing/speech.ulaw")
if err != nil {
b.Fatalf("Failed to read test data: %s\n", err)
}
b.SetBytes(int64(len(uData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Ulaw2Alaw(uData)
}
}