Skip to content

Instantly share code, notes, and snippets.

@joesis
joesis / context_bench_test.go
Created January 9, 2020 08:51
Demonstrate the difference between several values and map as value
package proxy
import (
"context"
"testing"
)
// Benchmark2Context-4 5373907 192 ns/op
// Benchmark10Context-4 678060 1493 ns/op
// Benchmark20Context-4 289543 4408 ns/op
@joesis
joesis / context_bench_test.go
Last active January 9, 2020 09:08
Demonstrate the performance difference between several values and map as value, both pre-initialized.
package proxy
import (
"context"
"testing"
)
// Benchmark2Context-4 26155296 47.0 ns/op
// Benchmark10Context-4 1892139 616 ns/op
// Benchmark20Context-4 479120 2401 ns/op
@joesis
joesis / smux_read_error.go
Created January 17, 2020 05:12
To demonstrate the case that all streams get read error after one read time out
package main
import (
"log"
"net"
"time"
"github.com/xtaci/smux"
)