From 8d2055d00ac682d7218d9e697a19a9ab5abb2e8b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 20 Apr 2017 19:05:57 +0300 Subject: [PATCH] fasthttputil: added TLS benchmarks for handshakes with elliptic curves --- fasthttputil/inmemory_listener_timing_test.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fasthttputil/inmemory_listener_timing_test.go b/fasthttputil/inmemory_listener_timing_test.go index 3518de9..28b42e2 100644 --- a/fasthttputil/inmemory_listener_timing_test.go +++ b/fasthttputil/inmemory_listener_timing_test.go @@ -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, }