• 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,
            })
            if err != nil {
                    b.Fatal(err)
            }
            defer c.Close()
            clen := int64(b.N) * 1024
            if _, err := c.Write([]byte(
                "POST / HTTP/1.1\r\nHost: foo\r\nContent-Length: " +
                fmt.Sprint(clen) + "\r\n\r\n")); err != nil {
                    b.Fatal(err)
            }
            b.ResetTimer()
            for i := 0; i < b.N; i++ {
                    if _, err := c.Write(buf); err != nil {
                            b.Fatal(err)
                    }
            }
    }
    
    Change-Id: I206e7e2118b97148f9751b740d8470895634d3f5
    Reviewed-on: https://go-review.googlesource.com/16828Reviewed-by: 's avatarAdam Langley <agl@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    5a0d9ef8
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
vendor/golang.org/x/net/http2/hpack Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...