• Brad Fitzpatrick's avatar
    crypto/tls, crypto/aes: remove allocations when Writing & Reading · 5a0d9ef8
    Brad Fitzpatrick authored
    benchmark          old ns/op     new ns/op     delta
    BenchmarkTLS-4     8571          7938          -7.39%
    
    benchmark          old MB/s     new MB/s     speedup
    BenchmarkTLS-4     119.46       128.98       1.08x
    
    benchmark          old allocs     new allocs     delta
    BenchmarkTLS-4     8              0              -100.00%
    
    benchmark          old bytes     new bytes     delta
    BenchmarkTLS-4     128           0             -100.00%
    
    On:
    
    func BenchmarkTLS(b *testing.B) {
            b.ReportAllocs()
            b.SetBytes(1024)
            ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                    io.Copy(ioutil.Discard, r.Body)
            }))
            defer ts.Close()
            buf := make([]byte, 1024)
            for i := range buf {
                    buf[i] = byte(i)
            }
            c, err := tls.Dial("tcp", ts.Listener.Addr().String(), &tls.Config{
                    InsecureSkipVerify: true,
            })
            ...
    5a0d9ef8
conn.go 28.3 KB