在本机测试为什么go循环这么慢?
如下代码循环要6-8秒,但是同样的代码写成php只要0.009秒左右,我哪里操作不对吗?
GO:
```
func main() {
st := time.Now().Unix()
str := ""
for i := 0; i < 100000; i++ {
str += "hello" + strconv.Itoa(i)
}
fmt.Println(time.Now().Unix() - st)
}
```
![1111111.png](https://static.studygolang.com/210914/803f8c3d44433a226c5c26fb1dc8e218.png)
PHP:
```
$t1 = microtime(true);
$str = '';
for ($i = 0; $i < 100000; ++$i) {
$str .= "hello" . (string)$i;
}
echo microtime(true) - $t1;
```
![php.png](https://static.studygolang.com/210914/33e90954198d17f52eea4efb1a22d379.png)
有疑问加站长微信联系(非本文作者)