Skip to content

Instantly share code, notes, and snippets.

@gsora
Created March 3, 2016 16:50
Show Gist options
  • Select an option

  • Save gsora/69e23b6c9af17e766f29 to your computer and use it in GitHub Desktop.

Select an option

Save gsora/69e23b6c9af17e766f29 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
for i := 0; i < 1000; i++ {
beforeGoroutine := time.Now()
afterGoroutine := make(chan time.Time)
go func() {
afterGoroutine <- time.Now()
}()
tAfter := <-afterGoroutine
duration := tAfter.Sub(beforeGoroutine)
fmt.Println("Goroutine spawn time: ", duration.Nanoseconds())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment