Skip to content

Commit daeadea

Browse files
author
shadowy-pycoder
committed
Added benchmarks for ssh parser
1 parent db72a3b commit daeadea

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

layers/ssh_test.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,43 @@ import (
88
"github.com/stretchr/testify/require"
99
)
1010

11-
func BenchmarkParseSSH(b *testing.B) {
12-
packet, close := testPacketBench(b, "ssh")
11+
func benchSSH(b *testing.B, path string) {
12+
b.Helper()
13+
ssh := &SSHMessage{}
14+
15+
packet, close := testPacketBench(b, path)
1316
defer close()
1417
b.ResetTimer()
15-
ssh := &SSHMessage{}
1618
for i := 0; i < b.N; i++ {
1719
_ = ssh.Parse(packet)
1820
fmt.Fprint(io.Discard, ssh.String())
1921
}
2022
}
2123

24+
func BenchmarkParseSSHProtoEx(b *testing.B) {
25+
benchSSH(b, "ssh_proto_ex")
26+
}
27+
28+
func BenchmarkParseSSHKeyExInitClient(b *testing.B) {
29+
benchSSH(b, "ssh_client_kex_init")
30+
}
31+
32+
func BenchmarkParseSSHKeyExInitServer(b *testing.B) {
33+
benchSSH(b, "ssh_server_kex_init")
34+
}
35+
36+
func BenchmarkParseSSHKeyExDHClient(b *testing.B) {
37+
benchSSH(b, "ssh_client_dh_kex")
38+
}
39+
40+
func BenchmarkParseSSHKeyExDHServer(b *testing.B) {
41+
benchSSH(b, "ssh_server_dh_kex")
42+
}
43+
44+
func BenchmarkParseSSHNewKeysClient(b *testing.B) {
45+
benchSSH(b, "ssh_client_new_keys")
46+
}
47+
2248
func TestParseSSHProtoEx(t *testing.T) {
2349
expected := &SSHMessage{Protocol: "SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.10"}
2450
ssh := &SSHMessage{}

0 commit comments

Comments
 (0)