分配
possibles
对于
default
案例:
default:
//possibles = nil
possibles = make([]string, 0, len(tryArr))
possibles = nil
2017/10/27 10:59:35 GOMAXPROCS: 4
2017/10/27 10:59:35 Starting 4 threads
2017/10/27 10:59:45 Id routine: 3 rate: 20.576132
2017/10/27 10:59:45 Id routine: 2 rate: 21.276596
2017/10/27 10:59:45 Id routine: 0 rate: 19.960080
2017/10/27 10:59:45 Id routine: 1 rate: 21.276596
2017/10/27 10:59:45 Current total rate was 83.09 K/s
2017/10/27 10:59:45 Starting 4 threads
2017/10/27 10:59:55 Id routine: 2 rate: 20.533881
2017/10/27 10:59:55 Id routine: 0 rate: 20.576132
2017/10/27 10:59:55 Id routine: 1 rate: 19.801980
2017/10/27 10:59:55 Id routine: 3 rate: 20.746888
2017/10/27 10:59:55 Current total rate was 81.66 K/s
57.08user 2.16system 0:20.02elapsed 295%CPU
和
possibles = make([]string, 0, len(tryArr))
,
2017/10/27 10:57:33 GOMAXPROCS: 4
2017/10/27 10:57:33 Starting 4 threads
2017/10/27 10:57:43 Id routine: 0 rate: 112.359551
2017/10/27 10:57:43 Id routine: 1 rate: 104.166667
2017/10/27 10:57:43 Id routine: 2 rate: 91.743119
2017/10/27 10:57:43 Id routine: 3 rate: 112.359551
2017/10/27 10:57:43 Current total rate was 420.63 K/s
2017/10/27 10:57:43 Starting 4 threads
2017/10/27 10:57:53 Id routine: 0 rate: 123.456790
2017/10/27 10:57:53 Id routine: 1 rate: 126.582278
2017/10/27 10:57:53 Id routine: 2 rate: 113.636364
2017/10/27 10:57:53 Id routine: 3 rate: 119.047619
2017/10/27 10:57:53 Current total rate was 482.72 K/s
58.11user 2.32system 0:20.01elapsed 302%CPU
你的结果是什么?
随着增加“
threads
“[1,2,3,4]和
,
$ cat /proc/cpuinfo | grep 'cpu cores' | uniq
cpu cores : 4
.
2017/10/27 11:19:03 GOMAXPROCS: 4
2017/10/27 11:19:03 Starting 1 threads
2017/10/27 11:19:13 Id routine: 0 rate: 285.714286
2017/10/27 11:19:13 Current total rate was 285.71 K/s
2017/10/27 11:19:13 Starting 1 threads
2017/10/27 11:19:23 Id routine: 0 rate: 312.500000
2017/10/27 11:19:23 Current total rate was 312.50 K/s
24.66user 1.13system 0:20.01elapsed 128%CPU
.
2017/10/27 11:19:28 GOMAXPROCS: 4
2017/10/27 11:19:28 Starting 2 threads
2017/10/27 11:19:38 Id routine: 0 rate: 238.095238
2017/10/27 11:19:38 Id routine: 1 rate: 217.391304
2017/10/27 11:19:38 Current total rate was 455.49 K/s
2017/10/27 11:19:38 Starting 2 threads
2017/10/27 11:19:48 Id routine: 1 rate: 192.307692
2017/10/27 11:19:48 Id routine: 0 rate: 217.391304
2017/10/27 11:19:48 Current total rate was 409.70 K/s
46.14user 2.07system 0:20.00elapsed 240%CPU
.
2017/10/27 11:19:53 GOMAXPROCS: 4
2017/10/27 11:19:53 Starting 3 threads
2017/10/27 11:20:03 Id routine: 2 rate: 142.857143
2017/10/27 11:20:03 Id routine: 1 rate: 149.253731
2017/10/27 11:20:03 Id routine: 0 rate: 147.058824
2017/10/27 11:20:03 Current total rate was 439.17 K/s
2017/10/27 11:20:03 Starting 3 threads
2017/10/27 11:20:13 Id routine: 2 rate: 153.846154
2017/10/27 11:20:13 Id routine: 1 rate: 156.250000
2017/10/27 11:20:13 Id routine: 0 rate: 153.846154
2017/10/27 11:20:13 Current total rate was 463.94 K/s
52.41user 2.21system 0:20.01elapsed 273%CPU
.
2017/10/27 11:20:25 GOMAXPROCS: 4
2017/10/27 11:20:25 Starting 4 threads
2017/10/27 11:20:35 Id routine: 1 rate: 106.382979
2017/10/27 11:20:35 Id routine: 2 rate: 102.040816
2017/10/27 11:20:35 Id routine: 0 rate: 125.000000
2017/10/27 11:20:35 Id routine: 3 rate: 117.647059
2017/10/27 11:20:35 Current total rate was 451.07 K/s
2017/10/27 11:20:35 Starting 4 threads
2017/10/27 11:20:45 Id routine: 1 rate: 111.111111
2017/10/27 11:20:45 Id routine: 2 rate: 112.359551
2017/10/27 11:20:45 Id routine: 0 rate: 119.047619
2017/10/27 11:20:45 Id routine: 3 rate: 128.205128
2017/10/27 11:20:45 Current total rate was 470.72 K/s
58.80user 2.20system 0:20.01elapsed 304%CPU
testing
package
基准设施。