Why does adding concurrency slow down this golang code?

后端 未结 4 1285
天涯浪人
天涯浪人 2020-12-12 19:31

I\'ve got a bit of Go code that I\'ve been tinkering with to answer a little curiosity of mine related to a video game my brother-in-law plays.

Essentially, the cod

4条回答
  •  既然无缘
    2020-12-12 19:43

    My results, which show substantial concurrency for 4 CPUs versus 1 CPU:

    Intel Core 2 Quad CPU Q8300 @ 2.50GHz x 4

    Source code: UPDATE (01/12/13 18:05)

    $ go version
    go version devel +adf4e96e9aa4 Thu Jan 10 09:57:01 2013 +1100 linux/amd64
    
    $ time  go run temp.go
    Number of CPUs:  1
    real    0m30.305s
    user    0m30.210s
    sys     0m0.044s
    
    $ time  go run temp.go
    Number of CPUs:  4
    real    0m9.980s
    user    0m35.146s
    sys     0m0.204s
    

提交回复
热议问题