Skip to content

Commit

Permalink
Updated benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
zaf committed Dec 29, 2016
1 parent 69dc1e0 commit 329137d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions alaw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func BenchmarkEncodeAlaw(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(rawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
EncodeAlaw(rawData)
Expand All @@ -37,6 +38,7 @@ func BenchmarkDecodeAlaw(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(aData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
DecodeAlaw(aData)
Expand All @@ -50,6 +52,7 @@ func BenchmarkAlaw2Ulaw(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(aData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Alaw2Ulaw(aData)
Expand Down
5 changes: 5 additions & 0 deletions g711_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func BenchmarkAEncode(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(rawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
encoder, err := NewAlawEncoder(ioutil.Discard, Lpcm)
Expand All @@ -123,6 +124,7 @@ func BenchmarkUEncode(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(rawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
encoder, err := NewUlawEncoder(ioutil.Discard, Lpcm)
Expand All @@ -145,6 +147,7 @@ func BenchmarkTranscode(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(alawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
transcoder, err := NewAlawEncoder(ioutil.Discard, Ulaw)
Expand All @@ -167,6 +170,7 @@ func BenchmarkUDecode(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(ulawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
decoder, err := NewUlawDecoder(bytes.NewReader(ulawData))
Expand All @@ -189,6 +193,7 @@ func BenchmarkADecode(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(alawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
decoder, err := NewAlawDecoder(bytes.NewReader(alawData))
Expand Down
11 changes: 7 additions & 4 deletions ulaw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func BenchmarkEncodeUlaw(b *testing.B) {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(rawData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
EncodeUlaw(rawData)
Expand All @@ -32,26 +33,28 @@ func BenchmarkEncodeUlaw(b *testing.B) {

// Benchmark DecodeUlaw
func BenchmarkDecodeUlaw(b *testing.B) {
aData, err := ioutil.ReadFile("testing/speech.ulaw")
uData, err := ioutil.ReadFile("testing/speech.ulaw")
if err != nil {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(uData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
DecodeUlaw(aData)
DecodeUlaw(uData)
}
}

// Benchmark Ulaw2Alaw
func BenchmarkUlaw2Alaw(b *testing.B) {
aData, err := ioutil.ReadFile("testing/speech.ulaw")
uData, err := ioutil.ReadFile("testing/speech.ulaw")
if err != nil {
log.Printf("Failed to read test data: %s\n", err)
b.FailNow()
}
b.SetBytes(int64(len(uData)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Ulaw2Alaw(aData)
Ulaw2Alaw(uData)
}
}

0 comments on commit 329137d

Please sign in to comment.