Skip to content

Instantly share code, notes, and snippets.

@emrekasg
Last active November 2, 2023 00:01
Show Gist options
  • Save emrekasg/f06865965066c32553dd40d0fcc08aae to your computer and use it in GitHub Desktop.
Save emrekasg/f06865965066c32553dd40d0fcc08aae to your computer and use it in GitHub Desktop.
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