= golang go test -cover -race -shuffle=on -vet=all -failfast == race conditions, CPU profiling and memory profiling ## based on https://github.com/bradfitz/talk-yapc-asia-2015/blob/master/talk.md 1. Write tests to catch data races. Run $ go test -v 2. Run with race detector. $ go test -v -race 3. To fix data race problems use functional style, mutex or atomic 4. Write benchmarks to do some CPU profiling: $ go test -v -run=^$ -bench=. 5. Collect data about the CPU: $ go test -v -run=^$ -bench=. -benchtime=2s -cpuprofile=prof.cpu 6. Run pprof to read created demo.test $ go tool pprof demo.test prof.cpu > top > top --cum > list handleHi > web # requires installation of graphviz 7. Memory profiling with --alloc_space $ go tool pprof --alloc_space demo.test prof.mem > top > top --cum > list BenchmarkHi > list handleHi