/usr/share/gocode/src/github.com/hashicorp/logutils/level_benchmark_test.go is in golang-github-hashicorp-logutils-dev 0.0~git20150609.0.0dc08b1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package logutils
import (
"io/ioutil"
"testing"
)
var messages [][]byte
func init() {
messages = [][]byte{
[]byte("[TRACE] foo"),
[]byte("[DEBUG] foo"),
[]byte("[INFO] foo"),
[]byte("[WARN] foo"),
[]byte("[ERROR] foo"),
}
}
func BenchmarkDiscard(b *testing.B) {
for i := 0; i < b.N; i++ {
ioutil.Discard.Write(messages[i%len(messages)])
}
}
func BenchmarkLevelFilter(b *testing.B) {
filter := &LevelFilter{
Levels: []LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: "WARN",
Writer: ioutil.Discard,
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
filter.Write(messages[i%len(messages)])
}
}
|