Skip to content

Commit

Permalink
add a benchmark test
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Dao <[email protected]>
  • Loading branch information
dqminh committed Jan 20, 2016
1 parent 4f441fa commit 8fa7145
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gelf/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
package gelf

import (
"compress/flate"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -228,3 +231,20 @@ func TestExtraData(t *testing.T) {
}
}
}

func BenchmarkWriteBestSpeed(b *testing.B) {
r, err := NewReader("127.0.0.1:0")
if err != nil {
b.Fatalf("NewReader: %s", err)
}
go io.Copy(ioutil.Discard, r)
w, err := NewWriter(r.Addr())
if err != nil {
b.Fatalf("NewWriter: %s", err)
}
w.CompressionType = flate.BestSpeed
b.ResetTimer()
for i := 0; i < b.N; i++ {
w.Write([]byte("This is a message"))
}
}

0 comments on commit 8fa7145

Please sign in to comment.