Performance
Go เร็วอยู่แล้ว แต่ถ้ารู้วิธี optimize จะเร็วขึ้นอีกหลายเท่า
Profiling - หา Bottleneck ก่อน
Section titled “Profiling - หา Bottleneck ก่อน”ก่อน optimize ต้องรู้ก่อนว่าช้าตรงไหน
# CPU profilinggo test -cpuprofile=cpu.prof -bench=.go tool pprof cpu.prof
# Memory profilinggo test -memprofile=mem.prof -bench=.go tool pprof mem.prof
# HTTP server profilingimport _ "net/http/pprof"# แล้วเข้า http://localhost:6060/debug/pprof/เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google