From d36728c9f30a43b9a2f68268ef8cc402a2740942 Mon Sep 17 00:00:00 2001 From: Tatsushi Demachi Date: Thu, 3 Sep 2015 05:04:17 +0900 Subject: [PATCH] Add numGoRoutines function --- fastping.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fastping.go b/fastping.go index 96950ca..349ec99 100644 --- a/fastping.go +++ b/fastping.go @@ -43,6 +43,7 @@ import ( "log" "math/rand" "net" + "runtime" "sync" "syscall" "time" @@ -105,6 +106,10 @@ func ipv4Payload(b []byte) []byte { return b[hdrlen:] } +func numGoRoutines() int { + return runtime.GOMAXPROCS(0) * 4 +} + type packet struct { bytes []byte addr net.Addr