Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (43 sloc) 1.098 kb
fd2e300 @shageman Rename package to gosteno
shageman authored
1 package gosteno
390b40f @anfernee Add performance benchmark
anfernee authored
2
3 import (
4 "testing"
5 )
6
7 func BenchmarkNoSink(b *testing.B) {
8 Init(&Config{})
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
9
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
10 loggers = make(map[string]*BaseLogger)
390b40f @anfernee Add performance benchmark
anfernee authored
11 logger := NewLogger("nosink")
12
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
13 performBenchmark(logger, b)
390b40f @anfernee Add performance benchmark
anfernee authored
14 }
15
16 func BenchmarkDevNullSink(b *testing.B) {
17 Init(&Config{
18 Sinks: []Sink{NewFileSink("/dev/null")},
19 })
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
20
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
21 loggers = make(map[string]*BaseLogger)
390b40f @anfernee Add performance benchmark
anfernee authored
22 logger := NewLogger("dev_null_sink")
23
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
24 performBenchmark(logger, b)
390b40f @anfernee Add performance benchmark
anfernee authored
25 }
26
27 func BenchmarkDevNullSinkWithLOC(b *testing.B) {
28 Init(&Config{
29 Sinks: []Sink{NewFileSink("/dev/null")},
30 EnableLOC: true,
31 })
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
32
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
33 loggers = make(map[string]*BaseLogger)
390b40f @anfernee Add performance benchmark
anfernee authored
34 logger := NewLogger("dev_null_sink_with_loc")
35
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
36 performBenchmark(logger, b)
390b40f @anfernee Add performance benchmark
anfernee authored
37 }
38
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
39 func BenchmarkDevNullSinkWithData(b *testing.B) {
390b40f @anfernee Add performance benchmark
anfernee authored
40 Init(&Config{
41 Sinks: []Sink{NewFileSink("/dev/null")},
42 })
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
43
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
44 loggers = make(map[string]*BaseLogger)
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
45 logger := NewLogger("dev_null_sink_with_data")
46 logger.Set("key1", "value1")
47 logger.Set("key2", "value2")
390b40f @anfernee Add performance benchmark
anfernee authored
48
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
49 performBenchmark(logger, b)
390b40f @anfernee Add performance benchmark
anfernee authored
50 }
51
b5e9451 Make every logger a taggable logger
Pieter Noordhuis and Tim Labeeuw authored
52 func performBenchmark(logger *Logger, b *testing.B) {
fdd8a19 @bluesalt fix the problem when running benchmark cases
bluesalt authored
53 b.ResetTimer()
54 for i := 0; i < b.N; i++ {
71cc65f Remove obsolete TaggedLogger
Pieter Noordhuis and Tim Labeeuw authored
55 logger.Info("Hello, world.")
390b40f @anfernee Add performance benchmark
anfernee authored
56 }
57 }
Something went wrong with that request. Please try again.