fasthttputil: added TLS benchmarks for handshakes with elliptic curves

This commit is contained in:
Aliaksandr Valialkin
2017-04-20 19:05:57 +03:00
parent 2c5a87147a
commit 8d2055d00a
@@ -53,6 +53,24 @@ func BenchmarkTLSHandshakeWithoutClientSessionCache(b *testing.B) {
benchmarkExt(b, handshakeHandler, bc)
}
func BenchmarkTLSHandshakeWithCurvesWithClientSessionCache(b *testing.B) {
bc := &benchConfig{
IsTLS: true,
DisableClientSessionCache: false,
UseCurves: true,
}
benchmarkExt(b, handshakeHandler, bc)
}
func BenchmarkTLSHandshakeWithCurvesWithoutClientSessionCache(b *testing.B) {
bc := &benchConfig{
IsTLS: true,
DisableClientSessionCache: true,
UseCurves: true,
}
benchmarkExt(b, handshakeHandler, bc)
}
func benchmark(b *testing.B, h fasthttp.RequestHandler, isTLS bool) {
bc := &benchConfig{
IsTLS: isTLS,
@@ -63,6 +81,7 @@ func benchmark(b *testing.B, h fasthttp.RequestHandler, isTLS bool) {
type benchConfig struct {
IsTLS bool
DisableClientSessionCache bool
UseCurves bool
}
func benchmarkExt(b *testing.B, h fasthttp.RequestHandler, bc *benchConfig) {
@@ -76,6 +95,12 @@ func benchmarkExt(b *testing.B, h fasthttp.RequestHandler, bc *benchConfig) {
Certificates: []tls.Certificate{cert},
PreferServerCipherSuites: true,
}
serverTLSConfig.CurvePreferences = []tls.CurveID{}
if bc.UseCurves {
serverTLSConfig.CurvePreferences = []tls.CurveID{
tls.CurveP256,
}
}
clientTLSConfig = &tls.Config{
InsecureSkipVerify: true,
}