-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Increase drain max depth from 8 -> 30 (#13063)
- Loading branch information
Showing
3 changed files
with
403 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package drain | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func BenchmarkDrain_TrainExtractsPatterns(b *testing.B) { | ||
tests := []struct { | ||
name string | ||
drain *Drain | ||
inputFile string | ||
}{ | ||
{ | ||
name: `Patterns for agent logfmt logs`, | ||
inputFile: `testdata/agent-logfmt.txt`, | ||
}, | ||
{ | ||
name: `Patterns for ingester logfmt logs`, | ||
inputFile: `testdata/ingester-logfmt.txt`, | ||
}, | ||
{ | ||
name: `Patterns for Drone json logs`, | ||
inputFile: `testdata/drone-json.txt`, | ||
}, | ||
{ | ||
name: "Patterns for distributor logfmt logs", | ||
inputFile: "testdata/distributor-logfmt.txt", | ||
}, | ||
{ | ||
name: "Patterns for journald logs", | ||
inputFile: "testdata/journald.txt", | ||
}, | ||
{ | ||
name: "Patterns for kafka logs", | ||
inputFile: "testdata/kafka.txt", | ||
}, | ||
{ | ||
name: "Patterns for kubernetes logs", | ||
inputFile: "testdata/kubernetes.txt", | ||
}, | ||
{ | ||
name: "Patterns for vault logs", | ||
inputFile: "testdata/vault.txt", | ||
}, | ||
{ | ||
name: "Patterns for calico logs", | ||
inputFile: "testdata/calico.txt", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
b.Run(tt.name, func(b *testing.B) { | ||
file, err := os.Open(tt.inputFile) | ||
require.NoError(b, err) | ||
defer file.Close() | ||
|
||
scanner := bufio.NewScanner(file) | ||
var lines []string | ||
for scanner.Scan() { | ||
line := scanner.Text() | ||
lines = append(lines, line) | ||
} | ||
|
||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
for _, line := range lines { | ||
drain := New(DefaultConfig(), nil) | ||
drain.Train(line, 0) | ||
} | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.