Created
December 26, 2023 08:48
-
-
Save gokhanm/ac62b9c716b69184d0ec5c69f7603c1e to your computer and use it in GitHub Desktop.
Revisions
-
gokhanm renamed this gist
Dec 26, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
gokhanm created this gist
Dec 26, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ // https://github.com/egonelbre/exp/blob/main/bench/goroutine/main.go package main import ( "fmt" "runtime" "sync" "github.com/loov/hrtime" ) func main() { const P = 128 const K = 100 const N = 10000 { bench := hrtime.NewBenchmarkTSC(K) for bench.Next() { var wg sync.WaitGroup wg.Add(P) for k := 0; k < P; k++ { go func() { for i := 0; i < N; i++ { runtime.Gosched() } wg.Done() }() } wg.Wait() } hist := bench.Histogram(10) hist.Divide(N * P / runtime.NumCPU()) fmt.Println("gosched\n", hist.StringStats()) } }