I'm a freshman for Golang. I know goroutine is an abstract group of cpu and memory to run a piece of code.
So When I run some computing funcs(like sort) in goroutines, I'm hoping they run parallel. But the printed result seems weird, the "paralell" codes print nearly the same timecost.
Why? Is there something I missed about goroutine, or it's because of the func printTime() ?
codes: https://play.golang.org/p/n9DLn57ftM
P.S. codes should be copied to local go file and run. Those run in play.golang has some limitation.
the result is:
MaxProcs: 8
Source : 2.0001ms
Quick sort : 3.0002ms
Merge sort : 8.0004ms
Insertion sort : 929.0532ms
Goroutine num: 1
Source : 2.0001ms
Goroutine num: 4
Insertion sort : 927.0531ms
Quick sort : 930.0532ms
Merge sort : 934.0535ms