mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 00:04:15 -04:00
Fix log plugin benchmark and slightly improve performance (#3004)
* log: use ioutil.Discard as write buffer in benchmark Using a buffer gives unrealistic stats and consumes a large amount of memory. * log: lazily check if a msg should be logged * log: improve variable name Change 'ok' to the more descriptive 'shouldLog'. * log: code comments: don't reuse variable
This commit is contained in:
committed by
Miek Gieben
parent
767d399877
commit
21e9c6047b
@@ -3,6 +3,7 @@ package log
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -239,8 +240,7 @@ func TestLogged(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkLogged(b *testing.B) {
|
||||
var f bytes.Buffer
|
||||
log.SetOutput(&f)
|
||||
log.SetOutput(ioutil.Discard)
|
||||
|
||||
rule := Rule{
|
||||
NameScope: ".",
|
||||
|
||||
Reference in New Issue
Block a user