go.crypto/ssh: add benchmarks for marshal and unmarshal
R=agl CC=golang-dev https://golang.org/cl/5730045
This commit is contained in:
committed by
Adam Langley
parent
67456e2aa3
commit
73a4e109cb
@@ -123,3 +123,37 @@ func (*kexDHInitMsg) Generate(rand *rand.Rand, size int) reflect.Value {
|
||||
dhi.X = randomInt(rand)
|
||||
return reflect.ValueOf(dhi)
|
||||
}
|
||||
|
||||
var (
|
||||
_kexInitMsg = new(kexInitMsg).Generate(rand.New(rand.NewSource(0)), 10).Elem().Interface()
|
||||
_kexDHInitMsg = new(kexDHInitMsg).Generate(rand.New(rand.NewSource(0)), 10).Elem().Interface()
|
||||
|
||||
_kexInit = marshal(msgKexInit, _kexInitMsg)
|
||||
_kexDHInit = marshal(msgKexDHInit, _kexDHInitMsg)
|
||||
)
|
||||
|
||||
func BenchmarkMarshalKexInitMsg(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
marshal(msgKexInit, _kexInitMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkUnmarshalKexInitMsg(b *testing.B) {
|
||||
m := new(kexInitMsg)
|
||||
for i := 0; i < b.N; i++ {
|
||||
unmarshal(m, _kexInit, msgKexInit)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMarshalKexDHInitMsg(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
marshal(msgKexDHInit, _kexDHInitMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkUnmarshalKexDHInitMsg(b *testing.B) {
|
||||
m := new(kexDHInitMsg)
|
||||
for i := 0; i < b.N; i++ {
|
||||
unmarshal(m, _kexDHInit, msgKexDHInit)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user