Last active
November 2, 2023 00:01
-
-
Save emrekasg/f06865965066c32553dd40d0fcc08aae to your computer and use it in GitHub Desktop.
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 characters
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/emrekasg/thread-locker/cpu" | |
) | |
func main() { | |
shardManager := cpu.NewShardManager() | |
startTime := time.Now() | |
defer func() { | |
fmt.Println("Total duration:", time.Since(startTime)) | |
}() | |
// run 250.000 task on each core except 4th core | |
for i := 0; i < 3; i++ { | |
for j := 0; j < 250e3; j++ { | |
shardManager.RunTask(i, ExampleFunc(j)) | |
} | |
} | |
fmt.Println("All tasks are completed") | |
generalInfo := shardManager.GetCoreInfo() | |
fmt.Printf("%+v", generalInfo) | |
fmt.Println("Total goroutine count:", shardManager.GetGoRoutineCount()) | |
} | |
func ExampleFunc(x int) func() { | |
return func() { | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment